How to configure nginx across domains? is nginx configured in the background or in the front end?

< H1 > Project background < / H1 >
  • front-end native ip:192.168.1.112 , background machine ip:192.168.1.140
  • the front end npm run dev runs in http://localhost:8080, and the address of the background http://192.168.1.140:9000

the front end requests the axios.get of the interface ("http://192.168.1.140:9000")
, please ask the front end to use nginx how to configure the proxy to solve the cross-domain problem?

Jun.22,2021

Cross-domain problems are solved in the background, and then configure the relevant headers that allow cors. Do not run on port 8080 after nginx


start the service. Guess that vue, can configure proxy directly in your project.


the project built by vue-cli introduces cross-domain plug-ins. Find the proxyTable entry in config/index.js and configure it like this:

proxyTable: {
      // proxy all requests starting with /api to jsonplaceholder
      'http://localhost:8080/': {
        target: 'http://192.168.1.140:9000', //
        changeOrigin: true,
        pathRewrite: {
          '^http://localhost:8080/': ''
        }
      }
    },
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-1b389d3-2c157.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-1b389d3-2c157.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?