javascript - I recently encountered the problem of post cross-domain when working on a project. I thought there was no way to do post cross-domain without a front-end, but it seems that there has been a turning point.
ringa_lee
ringa_lee 2017-05-19 10:07:35
0
4
575

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? ?

ringa_lee
ringa_lee

ringa_lee

reply all(4)
世界只因有你

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template