A
A
Andrew2021-10-22 07:37:36
CORS
Andrew, 2021-10-22 07:37:36

Error while requesting JSON data?

Good day. The situation is as follows:
there is a site example.io (for example). And with the help of a GET request to this page, you can get data about a specific user by specifying his id and authorization data in the request. And when sending a request through PostMan, everything works fine: the request leaves, the answer comes. But when copying the JS code (screen) from PostMan and trying to get data in the React application, an error occurs:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I searched for a solution in Google and Yandex, but did not find it. I also noticed that when sending a request through PostMan, new Cookies are sent each time. And in the react application, cookies are static, perhaps this is the reason?

Screen - 61723e79b0acd340611238.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-10-22
@wug1

Couldn't google Access-Control-Allow-Origin? Try again.
You can not send requests to someone else's site, if he explicitly does not allow it through the above header. Otherwise, any random site would write off all your money from all your bank clients.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question