Why is axios and react not working with express api?

Hello everyone,
So I have an express node api. I’ve tested it with postman and Get requests work perfectly. So I get this error in my console.

Access to XMLHttpRequest at 'http://localhost:8000/users' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Does anyone know a solution? Thank you in advance.

Nvm just found the answer. I justed needed to add a permission to my GET request route in express/node

    res.setHeader("Access-Control-Allow-Origin", "http://localhost:3000");

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.