sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.73k stars 112 forks source link

XML Sitemap getServerSideProps: 404 in production #3596 #338

Open nuhardlopen opened 6 months ago

nuhardlopen commented 6 months ago

Almost everything in my NextJS is getStaticProps. I only generate the dynamic XML Sitemaps with getServerSideProps. If I check it localhost it is working, in production the URL it is giving a 404. Also did a test without .xml extensions, just a getServerSideProps test page. Also gets a 404. Looks like the page is nog generated on the server with getServerSideProps.

Scherm­afbeelding 2023-12-23 om 16 28 21

Any ideas to fix this?

SST: 2.38.7 OpenNext v2.3.1 Next.js v14.0.2 https://discord.com/channels/983865673656705025/1027265626085019769/threads/1170375439664025773

nuhardlopen commented 6 months ago

I found the "issue". I have a dynamic route [slug].tsx directly after the root in pages folder. So I think that was the issue, and why it gaves 404 errors for other pages directly after the root in pages folder.

I have put the sitemaps in a separated folder in pages directory. Now everything is working fine.

Previous

pages
- [slug].tsx
- sitemap-blogs.xml.tsx
- sitemap-categorie.xml.tsx

Now

pages
- [slug].tsx
-- sitemap
--- sitemap-blogs.xml.tsx
--- sitemap-categorie.xml.tsx
khuezy commented 6 months ago

I'll keep this open. We need to investigate the .xml files, I think we may have overlooked that.