Next.js Starter Storefront Login Page Error on Google Cloud Run
The Next.js Starter Storefront uses parallel routes to show account pages. However, there's a reported error when hosting Next.js with parallel routes on Google's Cloud Run, where the error stops working.
Why this Error Occurred#
This error occurs because Google Cloud Run decodes chunk URLs, but Next.js expects them to be encoded.
How to Fix it#
To resolve the error, add the following rewrites in your Next.js Starter Storefront's next.config.ts file:
1const nextConfig = {2 // ... other config3 rewrites: async () => {4 return {5 beforeFiles: [6 {7 source: "/_next/static/chunks/app/:folder*/@login/:path*",8 destination: "/_next/static/chunks/app/:folder*/%40login/:path*",9 },10 // Repeat this pattern if other similar errors occur11 ],12 afterFiles: [],13 fallback: [],14 }15 },16}
You can add the rewrite to other parallel routes you have in your application. For example, if you have a /@dashboard route, you can add a rewrite for it as well.
Was this page helpful?