#CORS issue within next.js app

8 messages · Page 1 of 1 (latest)

deep halo
#

Hi so all day I've been trying to grab data from an external API. Using postman, I'm able to send a get request to it and it's fine; but when I use fetch to call the API in my next.js app, I get a cross origin error. Easy fix, just add the allow headers? But no, it cannot get it to work properly. I installed a CORS chrome extension and the localhost was able to call the request to the external API but that's obviously just a temp fix.

fetch('https://ANYAPI.cloud/api/info')
      .then(response => response.json())
      .then(data => setInfo(data))
      .catch(error => console.error(error));

I've looked up ways to workaround CORS but they either didn't work or were something unrelated. Is there some special configuration that I'm missing?

#

for fetch i previously tried mode: CORS and Access-Control-Allow-Origin etc

neon basalt
#

This is not something the frontend can fix

#

If you own anyapi.cloud, add cors headers to it

deep halo
neon basalt
#

Well idk flask so I can’t tell, but look up the documentation to see how to “allow” certain request origins

fleet frost