vue-cli 本地接口转发

采用vue-cli构建项目,接口转发如下

proxyTable: {

      '/api': {

            target: 'http://abcd.com/api',

            changeOrigin: true,

            pathRewrite: {

                '^/api': ''

            }

        }

    }

在开发环境下,配置了这个,可以解决在开发环境下的跨域请求,那么在生产环境下 通过 npm run build打包之后,这一块的问题vue-cli会自己处理吗?在生产环境下还需要注意什么东西?求大神解答

axios.post('api/auth/register', {

          'firstname':this.firstname,

          'lastname':this.lastname,

          'email':this.email,

          'password':this.password,

          'password_confirmation':this.configPassword

        })

        .then(function (response) {

          console.log(response.data);

        })

        .catch(function (error) {

          console.log(error);

        });

假设请求如上api(生产环境没有跨域),在本地配置接口转发之后可以请求到数据,那么在生产环境应该要怎么样?直接打包之后,将资源放在服务器吗?

慕森王
浏览 607回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript