Next.js Discord

Discord Forum

CORS error

Answered
French Lop posted this in #help-forum
Open in Discord
Avatar
French LopOP
How can I use an api which does not allow CORS? I am familiar with adding a proxy to my package.json but I think is not a good way to go? Because maybe i also want to access an other api and then I can’t use the same proxy.
Answered by tafutada777
Next.js has a mechanism that works as a reverse proxy. you can have multiple routes that point to different external apis.
https://nextjs.org/docs/app/api-reference/next-config-js/rewrites#rewriting-to-an-external-url
View full answer

2 Replies

Avatar
Next.js has a mechanism that works as a reverse proxy. you can have multiple routes that point to different external apis.
https://nextjs.org/docs/app/api-reference/next-config-js/rewrites#rewriting-to-an-external-url
Answer
Avatar
French LopOP
Thanks