About a question that the request doesn't work.

The common problem with

is that the server does not allow the front end to cross-domain, right? I know that it is a cross-domain problem, but the leaders do not know, please give some explanatory suggestions, it is also good to share the pot, thank you.

clipboard.png
clipboard.png

Mar.22,2021

of course, the server does not allow cross-domain, ah, such a problem is either the front-end agent cross-domain, or the background allows cross-domain. And your interface 500 is directly thrown to the background, ah, it is obvious that the pot in the background


500 is not the pot at the front end, and the setting problem of the code on the server side is
header ('Access-Control-Allow-Origin:*').
add this to allow other domain names to access


the local service you started. If it is nodejs, set proxy official address


these 500s and cross-domain are two problems.
be clear:
Cross-domain is just that the browser refuses js to get the data, but the data will still be transferred to the browser, and the browser can read the data. It should be 200 OK, instead of 500
your server is still reporting errors.

the second is the cross-domain problem. Cross-domain generally requires the backend to add three return header messages to inform the browser of the access rights to this resource.

  

Cross-domain will send an OPTIONS request before sending the real POST request. Now, even if POST, is a cross-domain problem, the pot is also at the front end, and the front end should send an OPTIONS request first, or the screenshot has not been captured.

Menu