我尝试将“http://localhost:3000/api/ ”路径重定向到在apache服务器上运行的“http://example.com/api/ ”。
我的devServer配置:
devServer: {
publicPath: '/build/',
port: 3000,
proxy: {
'/api': {
target: 'http://gestios.loc/api'
}
},
historyApiFallback: true
}
当我尝试访问http://localhost:3000/api/calltek/apps?permalink=empresas时收到404错误。
Request URL:http://localhost:3000/api/calltek/apps?permalink=empresas
Request Method:GET
Status Code:404 Not Found
Remote Address:127.0.0.1:3000
Referrer Policy:no-referrer-when-downgrade
HTTP/1.1 404 Not Found
X-Powered-By: Express
date: Fri, 05 May 2017 18:13:42 GMT
server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
vary: accept-language,accept-charset
accept-ranges: bytes
connection: close
transfer-encoding: chunked
content-type: text/html
content-language: es
答案 0 :(得分:5)
尝试添加
devServer: {
publicPath: '/build/',
port: 3000,
proxy: {
'/api': {
target: 'http://gestios.loc/api'
secure: false,
changeOrigin: true
}
},
historyApiFallback: true
}
我希望它有所帮助