Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuxtjs spa dynamic routes generate 404 after prod deployment

I am using nuxtjs

  • v.1.4.0
  • spa mode set in nuxt.config.js
  • with dynamic routing

When running in dev mode all urls work corretly, after npm run build and deployment to a weblogic server I can only access the webroot directly. From there the navigation to the dynamic routes work by clicking around. However, when I type in a URL (other than the webroot) that should translate to a dynamic route, I get a 404 (but this works in dev mode).

like image 783
Tamas Darvas Avatar asked Jun 21 '18 16:06

Tamas Darvas


2 Answers

Its because Dynamic routes are ignored by the generate command. You need to configure dynamic route generation by hand. See docs

like image 178
Aldarund Avatar answered Nov 12 '22 08:11

Aldarund


You need to add fallback: true to nuxt config generate parameter (docs). This redirects missing pages to 404.html which then loads the index.html

// nuxt.config.js
export default {
  generate: {
    fallback: true
  }
}
like image 36
yam Avatar answered Nov 12 '22 07:11

yam