Node.js vue.config.js文件中的代理规则
你能告诉我下列考虑是否正确吗Node.js vue.config.js文件中的代理规则,node.js,vue.js,Node.js,Vue.js,你能告诉我下列考虑是否正确吗 vue.config.js: module.exports = { //configure webpack-dev-server behavior devServer: { proxy: { '/api': { target: 'localhost:3000/', changeOrigin: true, pathRewrite: { '^/api': '' } }
vue.config.js:
module.exports = {
//configure webpack-dev-server behavior
devServer: {
proxy: { '/api':
{ target: 'localhost:3000/',
changeOrigin: true,
pathRewrite: { '^/api': '' }
}
} } }
考虑事项:
'/api':{target:'localhost:3000'..}
pathrewite:{'^/api':''}
^/api
是一个正则表达式
pathRewrite匹配目标地址中的/api路径段,并将其替换为空字符串(/api)
例如,对localhost:3000/api/1的代理请求将成为localhost:3000/1
全部正确还是有错误
谢谢似乎是正确的