Nextjs Export Redirect path without extension to path with .html

First of all thank you for the release of this product!

I have an app nextjs that I export in static and so I have a folder containing all my pages with the .html extension.

When the site is loaded and I click on a link in the page (next/link) the redirection is done. However, when I refresh the page, I get a 404 because he can’t find the page and expects to get .html at the end of the url.

Is it possible to redirect the url to automatically?

Kind regards

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

👋🏼 Like @crashoverride said this currently isn’t supported by App Platform however you can configure Next.js to generate the static HTML files in a way that allows you access the routes as /page instead of /page.html.

To enable this option, add the following to next.config.js:

module.exports = {
  trailingSlash: true,

This will generate the /page as /page/index.html instead of /page.html.

(documentation reference)

I’ve tested this and you can see an example in this repo:

next/link works in the same way as next/router. You only have more freedom with the last one. The problem does not come from there but from the resolution of the routes directly.

  1. Go to -> Click link => works
  2. Go to directly => does not work because there is no file that resolves this route.
  3. Go to => works

The only solution for the moment is to deploy a webserver and run the next start command. But in doing so I lose the capability of the cdn? Or create another component that contains the deployment of the output of the next build (_next dir and other files) and have a webserver component that will run next start.

This comment has been deleted