Static app hosted on S3 while using dynamic routes. Possible with App Router? #53173
Replies: 3 comments
-
|
I have created a minimum viable reproduction to showcase this difference in behavior of |
Beta Was this translation helpful? Give feedback.
-
|
Hi, AFAIK, this is a known issue. You can follow it here #48022 |
Beta Was this translation helpful? Give feedback.
-
|
Hi there! I have an easy fix for this. I'm having this issue too but what I made was a script that removes the ".html" part of the name of all the html files in the out/pages folder. This worked like a charm. If you want to test this without the script automation simply rename the html files in the pages folder in the S3 bucket to remove the ".html" part. Hope this helps someone. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With the pages router, it used to be possible to deploy a static Next.js app to an S3 bucket, even if the static app was built with dynamic routes. See #17711 for the discussion on this topic, and how this can be achieved by sprinkling a little bit of business logic into the 404 page.
My team is in the process of migrating our Next.js app, which is built in this ^^ way, from the Pages Router over to the App Router. However, we noticed that when exporting our app-router-based application, we are no longer seeing the dynamic segment HTML files in our
outfolder anymore.For example, let's say I have an app route named
app/hey/[slug]/page.tsx, with the contents of:We expect to find an
out/hey/[slug].htmlappearing in the build as a result of runningnext build. However, we get this build result:This route is interpreted as a server route, thus no
out/hey/[slug].htmlfile is created.I was able to get
next buildto detect this dynamic segment as a static route by adding the following toapp/hey/[slug]/page.tsx:However, I still don't see
out/hey/[slug].htmlappearing in the build.Does the Next.js team have plans to address this issue with the App Router, or is this viewed more as an "anti-pattern" (static export + dynamic routes) and thus have no plans to allow this going forward with the app router?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions