Create-react-app2.0 sets cross-domain proxy

create-react-app2.0 is different from the original when setting cross-domain proxy. This is a problem about setting cross-domain proxy on stackoverflow on create-react-app2.0

.

I installed this and configured the agent, but the combination of axios was not successful. I felt that there was a problem axios.defaults.baseURL of axios
because axios.defaults.baseURL was set to the agent name after setting the agent in vue, so I also configured it in react, but it didn"t seem to work axios.defaults.baseURL = "/ api"

.


1. creat-react-app configure

"proxy": {
    "/api": {
      "target": "http://10.100.23.126", //
      "changeOrigin": true
    }
  }

2.

axios  
baseURL: `${window.location.origin}/api`,

3. Actually use this.$http ('/ user/getList').

 http://10.100.23.126/api/user/getList

this is fine with mine.

For

cross-domain issues, don't focus on http request .
Please follow proxy :
when developing, you can deal with it directly by configuring proxy and webpack server in webpack or package.json . nginx can also easily handle cross-domain problems in
production environments.


prompts you to set Access-Control-Allow-Credentials: true

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8a75e-fdb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8a75e-fdb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?