Cross-domain issues are encountered in the front-end separation project. The solution is nothing more than Jsonp cors.
The project front-end does not take the node service, the line with Nginx site, nginx forwarding Ajax request server.
Cross-domain issues for the local development environment use node as the proxy to forward the request server (a perfect solution to the cross-domain problem of requesting server in the development environment).
The node code is as follows
"Use strict"; Const Express = require (' Express '); Const PATH = require (' path '); const APP = Express (); Const REQUEST = require (' request ');//Configure the static file service middleware let serverurl= ' http://220.231.2.29:7668 ';//server address App.use (express.static (Path.join (__ DirName, './')));//static resource index.html and node code in a directory App.use ('/', function (req, res) {let url = serverurl + req.url; Req.pipe (Request (URL)). pipe (res);}); App.listen ("127.0.0.1", function () {//Front-end Ajax address write http://127.0.0.1:3000/ console.log (' server is running at Port 3000 ');});
Nodejs Agent solves cross-domain problem of development environment