search

Home  >  Q&A  >  body text

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.

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_leeringa_lee2802 days ago595

reply all(4)I'll reply

  • 世界只因有你

    世界只因有你2017-05-19 10:09:35

    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

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:09:35

    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

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:09:35

    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

    reply
    0
  • 怪我咯

    怪我咯2017-05-19 10:09:35

    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

    reply
    0
  • Cancelreply