Vue 开发和生产环境的跨域

2019-07-17  本文已影响0人  最尾一名

背景

在 Vue 项目的开发过程中,我们经常会遇到跨域请求的问题,如果不做处理,这个问题就会影响项目的开发进度。

解决办法

module.exports = {
  lintOnSave: process.env.NODE_ENV !== 'production',

  productionSourceMap: false,

  devServer: {
    // ...
    proxy: {
      '/api': {
        target: 'xxx',
        changeOrigin: true
      }
  }
}
location /api {
    proxy_pass xxx/api;
  }
上一篇 下一篇

猜你喜欢

热点阅读