question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nuxt3 static mode runtime server fallbacks to index.html

See original GitHub issue

Environment


  • 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 from get-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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
danielroecommented, Aug 2, 2022

Then that is likely a configuration of your S3 environment in that case.

1reaction
lucassonsinlimacommented, Aug 2, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

The generate Property - Nuxt
Configure the generation of your universal web application to a static web ... If unset or set to a falsy value, the name...
Read more >
Run Nuxt 3 programmatically - typescript - Stack Overflow
Try running npm cache clean --force or npx nuxi clean before building. Your error may be the consequence of changing publicPathDir or other...
Read more >
Nuxt Configuration Reference
This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable. Example: NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs
Read more >
Going Full Static - NuxtJS
Bonus: you can run nuxt start to run a local server serving your generated static application. Note: in this video we are using...
Read more >
How to improve the PageSpeed score of your Nuxt.js website ...
The whole site is deployed in the static mode, meaning all pages are pre-generated and served as static HTML files, so no server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found