npm run build under nginx routing not working.
See original GitHub issueI have approx 6 routes in a spa app.
svelte-routing works perfectly with npm run dev
.
if I build with npm run build
and then run the app inside an nginx docker container, routes do not work.
eg. ‘http://localhost:8080/products’ and press enter … “404 Not Found … nginx/1.17.7”
does anyone have any ideas on where to look for the problem?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
React Router routes not working on nginx create-react-app
This fixes the React Router issues where you allow nginx to route traffic coming on different endpoints, directly to you React Application.
Read more >Nginx in not recognizing nested routes(react-router) after the ...
In locally react-router is working fine and i had not gotten any issue ... RUN npm run build # => Run container FROM...
Read more >Routes not working after npm build - Vue Forum
Today I tried npm run build. for production setup. The npm run build completed successfully and created dist folder within my vue.js app...
Read more >How To Deploy a React Application with Nginx on Ubuntu 20.04
To create a production build, use npm build. Stop the project by entering either CTRL+C or ⌘+C in a terminal.
Read more >Using NGINX to serve React Application (Static vs Reverse ...
We will keep our focus on the setup of Nginx with React . ... We run them using our node server that is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I understand it correctly
npm run build
do not generate physical files in/public
so nginx is trying to find non existing physical file and fails.If you want your SPA to work properly you must config your nginx to redirect all calls (with path intact) to
index.html
file. This fixed the same issues with exported Svelte/Sapper application that I was working on.I don’t know how to configure nginx but for Apache my working
.htaccess
is:Or use hash routing.
any example only nginx?