Next.js Discord

Discord Forum

Pages Router - Rewrites broken after upgrade from Next.js 12 to 13

Unanswered
Least Storm-Petrel posted this in #help-forum
Open in Discord
Least Storm-PetrelOP
After upgrading Next.js from v12 to v13 the url rewrites stopped working on deployments (AWS). Here is the example code from the next.config.js file.

async rewrites() {
  return {
    beforeFiles: [
      {
        source: "/api-v4/test",
        destination: '/api/test',
      },
    ],
  }
}


Local works as expected. Just not production build on AWS anymore.

Hitting the url /api/test responds correctly.
Hitting the url /api-v4/test responds with the html response of the 404 page.

Is there a step I might have missed when upgrading?

0 Replies