Nuxt.js 404 Static page

Written by haloboy777 on July 28, 2020

How to configure Nuxt.js to handle 404 error in static mode.


So this one took a long time to figure out. And I went so many places to find a fix this one. To be honest I wasn't looking that text/htmlmuch.

I'll spare you all the hacks I did. Turns out the solution was dead easy.


  • First open your nuxt.config.[js|ts] and specify the fallback page there

    export default {
    // Other Stuff
    generate: {
      fallback: "404.html"
  • Run npm run generate to generate all the static files, it will generate the dist folder.

  • Copy the dist folder to the root of your site.

  • Then go to your nginx config and tell it to serve this specific 404 page, assuming that the root of the server has all the files from dist.

    server {
    # routes and certificates
      error_page 404 /404.html;