vue.config.js 1.0 KB

123456789101112131415161718
  1. module.exports = {
  2. outputDir: 'shenze',
  3. publicPath: "/shenze",
  4. assetsDir: 'static',
  5. devServer: {
  6. open: true,
  7. proxy: {
  8. '/': { //前端任何含/api的URL请求都会被反向代理。如http://localhost:8000/xxx/api/source/xxx的请求会变成服务器的反向代理请求
  9. // target: 'http://127.0.0.1:49011', //原来请求的服务器IP地址会换成此地址,如以上地址会变成http://localhost:5000/xxx/api/source/xxx
  10. target: 'http://112.74.63.148:49011', //原来请求的服务器IP地址会换成此地址,如以上地址会变成http://localhost:5000/xxx/api/source/xxx
  11. changeOrigin: true, // 是否跨域
  12. pathRewrite: {
  13. // '.+?/api': '/api'
  14. } // 这里会对反向代理的地址进行重写。比如我的实际后端资源的URI是http://localhost:5000/api/resource,那么不加这个配置属性的话是访问不到我这个有效地址的。这里配置是一个正则替换,替换后就是后端api真正有效的地址了
  15. }
  16. }
  17. }
  18. }