Vue跨域失败Error occurred while trying to proxy request
2023-03-09 16:59:42    0    0    0
junjie
Vue跨域配置如下: ``` proxyTable: { '/api': { target: 'http://localhost:4000', changeOrigin: true, pathRewrite: { '^/api': '' } } }, ``` 然而启动之后报错,意思是代理请求转发失败 ``` [HPM] Error occurred while trying to proxy request /position/40.10039,116.36868 from localhost:8082 to http://localhost:4000 (HPE_INVALID_CONSTANT) (https://nodejs.org/api /errors.html#errors_common_system_errors) ``` proxyTable的配置肯定是生效了,但是没有配置正确,把localhost改为本机的ip即可。在许多地方用localhost会有点问题,具体原因待查,最好用ip。 ``` proxyTable: { '/api': { target: 'http://127.0.0.1:4000', changeOrigin: true, pathRewrite: { '^/api': '' } } }, ``` 作者:斑马线cow 链接:http://events.jianshu.io/p/5af043b340e6 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

上一篇: Jquery获取动态添加的元素

下一篇: MySQL 报错 incorrect datetime value ‘0000-00-00 00:00:00‘ for column

Table of content