N
Nuxt6d ago
心靈

nitro autoSubfolderIndex:false preview 404

When i set nitro autoSubfolderIndex:false ,and use generate and perview,in localhost:3000 any routes always 404. What else do I need to configure😢 export default defineNuxtConfig({
compatibilityDate: '2025-05-15', devtools: { enabled: true }, sourcemap: { server: true, client: true }, ssr: false, nitro: { prerender: { autoSubfolderIndex: false, }, } });
No description
4 Replies
kapa.ai
kapa.ai6d ago
Hi @心靈. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- When you set nitro.prerender.autoSubfolderIndex: false, Nuxt will generate flat HTML files like /about.html instead of /about/index.html. However, when you use nuxi generate and then run nuxi preview (or serve the .output/public folder), you may encounter 404 errors for all routes except the root. This happens because, with autoSubfolderIndex: false, requests to /about will not match /about.html unless your static server is configured to serve .html files for extensionless URLs. The built-in preview server (nuxi preview) does not automatically handle this mapping. What you can do: - To preview your site locally, access the routes with the .html extension (e.g., <http://localhost:3000/about.html>). - If you want extensionless URLs to work (e.g., /about), you need a static server that rewrites requests for /about to /about.html. The default Nuxt preview server does not do this out of the box. - For production, configure your static hosting (like Netlify, Vercel, or nginx) to rewrite extensionless URLs to their .html counterparts. Summary:
This is expected behavior with autoSubfolderIndex: false and the default preview server. There is no additional Nuxt configuration to change this behavior for nuxi preview. You must either use the .html extension in your URLs or set up custom rewrites on your hosting platform to support extensionless URLs. The knowledge sources confirm the effect of autoSubfolderIndex: false but do not mention a built-in way to make the preview server handle extensionless URLs automatically. If you need this locally, consider using a static server like serve or http-server with custom rewrite rules, or access the .html files directly see example config. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6d ago
<@929218995276627968> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
心靈
心靈OP6d ago
if i open localhost:3000/login.html ,it will navigateTo localhost:3000/login,how can i to fix it @kapa.ai
kapa.ai
kapa.ai6d ago
Let me check the knowledge base for you again. One moment! :books: Sorry @心靈, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?

Did you find this page helpful?