search

Home  >  Q&A  >  body text

javascript - After vue-cli is released, how to remove the cross-domain proxyTable configuration set in the development environment from the interface address

During development, we used cross-domain because we were in two places, and set it in config/index

proxyTable: {
  '/api': {
    target: 'http://xxx',
    changeOrigin: true,
    pathRewrite: {
      '^/api': '/api'
    }
  }
}

Now after building, when putting the project on the server, all interfaces still exist in /api/, but this is no longer needed. Is there any way to do this? The configuration was removed.

漂亮男人漂亮男人2752 days ago819

reply all(3)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-26 10:56:47

    if (process.env.NODE_ENV === 'development') {
        let api = '/api/'
    } else {
        let api = ''
    }

    Try this

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-26 10:56:47

    This one on my side is only used locally, and nginx is used as a proxy in the online environment.

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-26 10:56:47

    After you build, you are no longer running dev-server.
    This cross-domain can be ignored

    reply
    0
  • Cancelreply