Next.js Discord

Discord Forum

Rewrites not working during build on 13.5.5

Unanswered
MoonSoD posted this in #help-forum
Open in Discord
So after a while of debuging my newly updated nextjs 13.5.5 build, I've discovered that rewrites stopped working during build for some reason. Using rewrites to proxy our API so I can handle auth ussing sessions.

When I build my app, the build fails due to "fetch failed". When I open another terminal with next dev and then I try to build the app using next build suddenly the fetch works fine 🙂

...
    async rewrites() {
      return [
        {
          source: "/store-api/:path*",
          destination: `${process.env.NEXT_PUBLIC_MEDUSA_API_URL}/:path*`,
        },
      ]
    },
...

0 Replies