Next.js: Next export: making links and static folder work locally?

Created on 28 May 2017  路  2Comments  路  Source: vercel/next.js

After running next export and opening the out/index.html on my dev machine in the browser, the links won't work. E.g a link to /courses will point to file:///courses/.

Also, assets from the /static folder won't be linked properly either. E.g if there's an <img src='/static/bla.png'>, it will try to load it from file:///static/bla.png.

Is there any way to fix this within next.js to allow testing exports locally instead of needing to deploy every time?

Most helpful comment

You don't need to deploy it. Just run a local HTTP server. Here's the simplest one:

python -m SimpleHTTPServer

Then you can access your app in http://localhost:8080

Serving the folder directory without a HTTP server is not a goal we need to go for.

All 2 comments

You don't need to deploy it. Just run a local HTTP server. Here's the simplest one:

python -m SimpleHTTPServer

Then you can access your app in http://localhost:8080

Serving the folder directory without a HTTP server is not a goal we need to go for.

You can also use serve -s (npm install -g serve) from ZEIT 馃憣

Was this page helpful?
0 / 5 - 0 ratings