天蓬老师2017-04-18 10:57:24
Set response.setHeader("Access-Control-Allow-Origin", "*"); in the background
You can also configure it on the nginx side to solve the problem.
jsonp is not a particularly good method, it has size limitations on the data transferred.
PHP中文网2017-04-18 10:57:24
CORS. Since it is front-end and back-end analysis, just set the header in the background
PHP中文网2017-04-18 10:57:24
It is not recommended to use jsonp cross-domain. Although this ancient method has good compatibility, it has great limitations and has the risk of XSS.
Relatively complete separation of front-end and back-end, of course, means that front-end personnel manage the web server. Of course, this requires relatively high requirements for front-end personnel.
If you just want to adjust the interface, it is better to set up a local test server yourself. It is used as a static server for the page, which is convenient for adjusting the page, and can forward the request and request the data.
You can use express yourself, or you can use ready-made ones like browsersync+gulp or webpack+hot reload server.
I use browsersync, the configuration is very convenient, you can refer to this.
黄舟2017-04-18 10:57:24
There is a chrome plug-in, what it does is response.setHeader("Access-Control-Allow-Origin", "*") , just turn it on.
阿神2017-04-18 10:57:24
WebSocket is not subject to cross-domain restrictions and can transmit any data, including jsonp.
天蓬老师2017-04-18 10:57:24
By the way, shouldn’t this be decided before development? Isn’t it a little late to decide whether it’s jsonp or cors until joint debugging?