serving dist directory through nginx fails
See original GitHub issueI’ve been trying to deploy my app the past couple of days using nginx. It definitely works when using express and pointing the dist folder, using: app.use(express.static('dist'));
The problem is when serving it through nginx using a location block. I have the following location block
location /myblog {
alias /app/blog/dist;
index index.html index.htm;
}
It hits the route, loads the index.html, .js & .css, but it renders an empty app. Any thoughts??
<body style="background:#fff;font-family:Helvetica"><div id="app">
<!-- react-empty: 1 --></div>
<script type="text/javascript" src="/main.746946c56bcce138a405.js"></script>
</body>
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Serving Static Content | NGINX Plus
Configure NGINX and NGINX Plus to serve static content, with type-specific root directories, checks for file existence, and performance optimizations.
Read more >Nginx is not serving the static files that have been collected ...
Nginx is not serving the static files that have been collected inside the project directory. ... I have seen others face the same...
Read more >Why is nginx serving static files out of the wrong directory?
I am trying to get nginx to serve a static file from the root url eg. http://localhost/favicon.ico . My static assets are located...
Read more >How To Serve Static File Directory Over HTTP Using NGINX
You are getting 403 forbidden error most probably because of the wrong permissions. Make sure that /media/user/data is readable by nginx user.
Read more >Can the “dist” folder be redirected? : r/nginx - Reddit
Hi I'm new using nginx, I get stuck by configuring a reverse proxy. I have service running in docker on port 8080 (internal/external)...
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
I’ve confirmed it works just fine when served from web root. (which is as designed)
Steps to reproduce:
Step 4 will open a lightweight http server that serves files from dist. The app works fine for me. So this proves it works fine with a plain webserver that simply serves static files.
The issue is with the default route. You need to add a default route to links in the router and then it works. So, this issue is not related to react sligshot