Vue项目打包后找不到请求地址?

/config/index.js

proxyTable: {
    // proxy all requests starting with /api to jsonplaceholder
    '/api': {
        target: 'https://xxxxxxx.com/',
        changeOrigin: true,//是否跨域
        changeOrigin: true,
        pathRewrite: {
            '^/api': ''
        }
    }
},

开发模式下是可以正常获取到响应的,请求能发到测试服务器上,但打包后就找不到了。

报错 *n:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:9000/api/app/getCheckNumImg.action

图传不上来,文字代替一下。

怎么让打包后请求指向的是真正的测试服务器地址呢?

阅读 15.5k
1 个回答

开发的时候用的dev_server只针对开发的时候用的,打包后dev_server这块配置的请求代理已经无效了。
把路径改成服务端的地址就可以啦!
eg: 直接https://xxxxxxx.com/...

推荐问题