Enable CORS- use web dev API for reactjs

I have a question about the consumption of information with API.
generate an API in web dev at the time of testing in postman everything is fine

but when consuming it in react it throws me the following error:
Access to fetch at ‘from origin’ http: // localhost: 3000 ‘has been blocked by CORS policy: 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.

some solution without using chrome extensions is frontend or ignition server problem

As previously mentioned, you have the ability to return your own OPTIONS headers in Webdev. You have to write the code yourself to return the right header values. If you have some code written and it’s not working, provide your code.

You’re looking for a single solution to a problem for which there is no single solution. The right CORS headers to use are going to depend on your application. You must do the research yourself.

1 Like