vuepress
vuepress copied to clipboard
在config.js里配置了configureWebpack的devServer.proxy,但是实际访问没起作用
在vuepress的config.js里配置了configureWebpack,如下:
configureWebpack: (config) => { config.devServer = { proxy: { '/test/aaa': { changeOrigin: false, target: 'https://www.runoob.com/', pathRewrite: { '^/test': '/test' } } } } },
但是实际上在vue里调用‘/test’,浏览器页面上的请求 http://localhost:8080/test 返回404,好像上面配置的proxy没起作用, 请问这块我想本地调用别的网站的api,这里如何设置才能好用呢,非常感谢。
我的也不行
有解决吗
很大可能是因为 proxy 的 pathFilter 配置错误,参考文档
devServer: {
proxy: {
// url 地址为: `/a/api/b/c`
// `**/api/**` 有效,而 `/api` 或者 `**/api` 均无效
'**/api/**': {
target: 'https://localhost:8989',
},
},
},
配置到configWebpack当中似乎不会生效,需要在最外层才会生效