Invalid vue-cli configuration proxyTable

projects created using vue-cli 2.9

  • config/index.js
this.$http
  .post("/UTRY/tsupport_workbench/rest/loginCtrl/getMenu")

restart and delete node_modules have all been tried, and there is no sign of proxy.
console or cross-domain report

Access to XMLHttpRequest at "http://192.168.0.143:9300/UTRY/tsupport_workbench/rest/loginCtrl/getMenu" from origin "http://127.0.0.1:8080" has been blocked by CORS policy: Response to preflight request doesn"t pass access control check: No "Access-Control-Allow-Origin" header is present on the requested resource.

Network

Request URL: http://192.168.0.143:9300/UTRY/tsupport_workbench/rest/loginCtrl/getMenu

how should I configure it?


now that the proxy has been configured, axios does not need to set baseURL , otherwise it will not be processed by the agent.


const baseURL = "http://192.168.0.143:9300"
Change

to

const baseURL = ""

after setting proxyTable, you can no longer set baseURL


Cross-domain problem handling: the development environment uses proxyTable to configure the reverse proxy, while in the production environment, if the nginx server is used, the reverse proxy can be configured on the nginx, so the interface domain name is generally configured on the server

.
Menu