#Nuxt 4, Nitro, SSR, Netlify => after F5 get 404!

1 messages · Page 1 of 1 (latest)

runic river
#

Web seems to be Ok, all links are fully working, but when im press on current url (does not matter if im stand on /contact or /members ...) F5
I get netlify 404 "Page not found
Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site.

If this is your site, and you weren’t expecting a 404 for this path, please visit Netlify’s “page not found” support guide for troubleshooting tips."

build is correct without any errors

netlify.toml

[build]
publish = "dist"
command = "pnpm run build"

[build.environment]
NODE_VERSION = "20"

[[redirects]]
from = "/*"
to = "/.netlify/functions/server"
status = 200

SSR is turned on (on local, everything works fine)

Any adea? 😭

sullen sentinelBOT
#

Hi @runic river. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Netlify is serving its own 404 page, which means the request is not reaching your Nuxt/Nitro server at all. The knowledge sources don’t contain a Netlify + Nuxt 4 SSR–specific guide, so the following is based only on patterns visible in similar hosting issues and may not cover all required Netlify config.

A few things to check:

  1. Ensure Netlify is actually using your function path

    Your redirect:

    [[redirects]]
      from = "/*"
      to = "/.netlify/functions/server"
      status = 200
    

    is the right idea for SSR, but if Netlify doesn’t find a function called server, it will fall back to its own 404. Make sure your Nuxt/Nitro build is actually outputting a Netlify Functions handler with that name (e.g. .netlify/functions/server in the deploy bundle). The knowledge sources don’t show how Nuxt 4 + Nitro names the Netlify function, so I can’t confirm the exact function name from them.

  2. Avoid a catch‑all 404 redirect before SSR

    If you also have a /* -> /404.html rule before the SSR rule, Netlify will match that first and never reach your SSR handler. This exact ordering problem is shown in the Netlify + Nuxt static example: the 404 rule must be last, otherwise all other redirects are bypassed. [Netlify redirects]

    So if you have something like:

    [[redirects]]
      from = "/*"
      status = 404
      to = "/404.html"
    
    [[redirects]]
      from = "/*"
      to = "/.netlify/functions/server"
      status = 200
    

    then the 404 rule will always win. The SSR rule must come before any /* 404 rule, or the 404 rule must be removed entirely.

  3. Confirm that 404s are handled by Nuxt, not Netlify

#

For static sites, you typically generate a 404.html and then wire Netlify to it. [Netlify redirects] For SSR, you usually want Nuxt’s own error.vue / 404 handling to run instead of Netlify’s. That means:

  • No /* -> /404.html rule that intercepts all unknown paths.
  • Let the SSR function handle unknown routes and render Nuxt’s error page. Nuxt’s own error handling (e.g. error.vue) is documented separately. [Nuxt error component]

If, after:

  • verifying that the server function actually exists in the deployed bundle, and
  • ensuring there is no earlier /* 404 redirect that shadows your SSR rule,

you still get Netlify’s 404 on F5, then the missing piece is likely in the Netlify–specific SSR adapter configuration, which is not covered in the provided knowledge sources.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@runic river Kapa.ai is still learning and improving, please let me know how I did by reacting below.