Nuxt.js: Static build does not work, assets not found 404

Created on 14 Jun 2017  路  9Comments  路  Source: nuxt/nuxt.js

So I built my project, and hit npm run build. The files appear in my dist folder, all bundled up. However, it doesn't work. When I try and upload the files to a server I get a bunch of 404 errors that none of the bundled files can be found.

I don't understand if this has something to do with dynamic routes. For my project, all I did was make a new .vue file for each page. I don't think these are dynamic routes. I don't understand the documentation. You have to make a .vue file to define dynamic routes? or you put them in nuxt.config.js?

This question is available on Nuxt.js community (#c761)
help-wanted

Most helpful comment

Have you tried router.base option?

All 9 comments

Hi @jzucadi,
If you want to create a static web app, you need to use the generate command.
For dynamic routes, what do you not understand in the documentation example?

@alexchopin It seems it only works if the site is in root folder. In other words, it works for http://example.org but not for http://example.org/my-site. Non-working example here: https://rap2hpoutre.github.io/nuxt-news/ (you can see 404 for each js file)

I think it's because links are created like this /_nuxt/vendor.bundle.72592248950c00528b87.js (so root level). Is there a workaround?

Have you tried router.base option?

@alexchopin Great! Fixed! (and sorry, I did not see that)

OK, I think my first mistake was that I was using the adonuxt template which does not have a generate command. As far as the documentation, here is what I am trying to figure out: do I need to do something extra regarding defining page routes to get them to work? If I just made some pages (each in a standalone .vue file) is the routing that nuxt does automatically enough?

@jzucadi yes nuxt does it automatically, you only need to define dynamic route for the generate command to let nuxt knows the routes params values.

ok thank you. Sorry, need to go through documentation again.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lazycrazy picture lazycrazy  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

msudgh picture msudgh  路  3Comments

vadimsg picture vadimsg  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments