Dynamic routes 404 only on production SSR site, and only after partial conversion to Typescript
Answered
Cape lion posted this in #help-forum
Cape lionOP
I have a NextJS Javascript app that has no static pages — all SSR pages using data from a data provider server. Some pages have static paths but many have dynamic paths based on data from the data provider. I have defined most of these paths under pages/example-path/[id].js, and that code generally has a
This has been working fine in both development and production builds for quite some time. The problem started when I converted a couple small non-React library files from Javascript to Typescript. With a development build, the entire site works fine and passes our Cypress and Jest tests. Navigating to pages with both dynamic and static paths loads the JSON for the page and doesn’t cause any page reloads.
But with a production build, loading a page at a static path works fine, though you might see prefetches to some links on the page to dynamic-path pages 404. Then clicking on a link to a page with a dynamic path:
1. Causes a full page reload, which doesn’t happen if you go to a page with a static path
2. The page renders the static HTML
3. You then see a 404 for paths like http://localhost:3000/_next/static/chunks/pages/human-donors/%5Buuid%5D-ff39346480f92981.js when I try to load the page with the path /human-donors/dynamic-id/
I’ve attached my next.config.js file.
getServerSideProps() and a rendering component.This has been working fine in both development and production builds for quite some time. The problem started when I converted a couple small non-React library files from Javascript to Typescript. With a development build, the entire site works fine and passes our Cypress and Jest tests. Navigating to pages with both dynamic and static paths loads the JSON for the page and doesn’t cause any page reloads.
But with a production build, loading a page at a static path works fine, though you might see prefetches to some links on the page to dynamic-path pages 404. Then clicking on a link to a page with a dynamic path:
1. Causes a full page reload, which doesn’t happen if you go to a page with a static path
2. The page renders the static HTML
3. You then see a 404 for paths like http://localhost:3000/_next/static/chunks/pages/human-donors/%5Buuid%5D-ff39346480f92981.js when I try to load the page with the path /human-donors/dynamic-id/
I’ve attached my next.config.js file.
Answered by Cape lion
I no longer see the problem I described once I downgraded NextJS 13.4.13 back to 13.4.12. It had nothing to do with my Typescript conversion.
4 Replies
Cape lionOP
I no longer see the problem I described once I downgraded NextJS 13.4.13 back to 13.4.12. It had nothing to do with my Typescript conversion.
Answer
hmm probably a nextjs bug then, why are there so many bugs in 13.4.13 

American Crocodile
Hi, I spent hours on the same exact issue. Turns out downgrading to 13.14.12 solved the issue. I wonder if there's a Github issue open somewhere?