Because background requests from new companies are basically post requests, cross-domain problems will inevitably occur when working on projects. In my dictionary, the get request can be solved through jsonp, but the post request seems to be only possible by changing the server's header A-C-A-O. But today my backend colleague told me that it seems that the Chrome browser can solve the cross-domain problem through settings, like this
So I tried it, but the result seemed to be unsatisfactory. So I would like to ask everyone here, whether this method is reliable? ?
1.jsonp
2. Server setting header
3.Server proxy
4.XMLHttpRequest Level 2
Of course there are other ways. But these are the simplest and easiest ways to implement in my opinion
If you use a build tool such as webpack, there are corresponding proxy plug-ins, which can be configured to proxy cross-domain. There are also many other static file servers, such as the server-static I have been using
I also encountered cross-domain problems when I was using Vue to do projects. At that time, all get requests were OK, but Post was not. Later, I checked the data through a library called qs, qs.stringify the data to be Posted, and then That’s it
If you are in the development stage, there is no problem.
But I still recommend that the backend cross-domain through
cors
. This is the current standard practice