nuxt3 static mode runtime server fallbacks to index.html
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.16.0
- Nuxt Version:
3.0.0-rc.6
- Package Manager:
npm@7.24.2
- Builder:
vite
- User Config:
ssr
,target
,generate
,modules
,css
,vite
,intlify
,runtimeConfig
,app
,nitro
- Runtime Modules:
@intlify/nuxt3@0.2.3
,@pinia/nuxt@0.3.1
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-1aqsxa-tca2sg?file=nuxt.config.ts
npm run generate
npm run preview
- navigate to
/get-started
path - see the blinking
hello from root/index
or view the source code, isnt the source code fromget-started.vue
Describe the bug
When I use generate
to build static files and serve to any static hosting, if I navigate to any route different from /
, the index.vue
content blinks before the route resolves. Following nitro docs I’ve customized nitro commands section to something like that:
nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
target: 'static',
nitro: {
commands: {
preview: 'npx serve .output/public'
}
}
})
You can notice that I removed the -s
args from serve
, cause based on docs I believe this -s
is the one that is adding this index.html
fallback to any routes. Maybe Nuxt routing is handling all routes as not found requests, dont know if this is expected. This example works in dev preview, but when I deploy my static files to S3, this behavior still exists. I tried to use the same custom command at deploy
on nitro, but didn’t works 😕
Is there any way to remove this -s
argument from runtime server when static files are deployed? Or is there any way to remove this fallback from static files? I already tried fallback
option too
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Then that is likely a configuration of your S3 environment in that case.
Thank you so much for expliciting this, it led me to solve this turning my S3 into static host and poiting my cloudfrount to S3 static host URL. Do you think we should create a docs for this or its something that should be known when working with AWS? Honestly its my first time using this whole stack so I don’t know if it attends to other static + AWS needs. I can help creating this if needed