webpack proxy 不生效

配置的代理未生效,还是会报跨域请求,请问下,配置哪里有问题
谢谢
wepack.config.dev.js:

devServer: {
    inline: true,
    port: 3333,
    historyApiFallback: true,
    proxy: {
      '/crm-manage-web/': {
        target: 'http://192.168.27.27:7002',
        secure: true,
        changeOrigin: true
      }
    }
  },

package.js:

"scripts": {
  "start": "webpack-dev-server --devtool eval --progress --colors --content-base build --config ./webpack.config.dev.js",
  "build": "webpack -p --config ./webpack.config.pro.js"
},

console.log:

10% building 2/2 modules 0 activeℹ 「wds」: Project is running at http://localhost:3333/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/eddie/Desktop/mofang_project/mofang_crm/build
ℹ 「wds」: 404s will fallback to /index.html
ℹ 「wdm」: Hash: 011d083fb80732801c95

客户端:
image.png
console:

  Access to XMLHttpRequest at 'http://192.168.27.27:7002/crm-manage-web/login/login' from origin 'http://127.0.0.1:3333' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
阅读 13.4k
2 个回答

你的ajax的baseURL需要设置为空或者localhost:8080,
clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题