Next.js Discord

Discord Forum

next.config.js rewrites question

Unanswered
Scale parasitoid posted this in #help-forum
Open in Discord
Scale parasitoidOP
async rewrites() {
  return [
    {
      source: '/api/:path*'
      destination: `${process.env.NEXT_PUBLIC_API_HOST}/:path*`,  // API HOST has different domain address.
    }
  ]
}

I thought rewrites are working as proxy server.
GET reqeust to API server is working fine, however, I am facing CORS error from browser on POST, PUT, DELETE request.

Am I missing something?

0 Replies