I'm trying to call an external API using rewrites from Next server to avoid CORS error. To do that I've been reading Next docs Rewrites but is not working for me.
My next.config.js file is like this:
module.exports = {
reactStrictMode: true,
async rewrites() {
// let externalServer = process.env.EXTERNAL_API_URL
return [
{
source: "/api/:path*",
destination: "https://localhost:50575/api/:path*",
},
]
},
}
I have tried to use that package, but if you see that page recomend use rewrites because works like a proxy, if I'm not misunderstanding.
The rewrites seems not working it just fetching data from Next server instead external API,I don't have any error at all.