question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

serving dist directory through nginx fails

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
coryhousecommented, Jul 26, 2016

I’ve confirmed it works just fine when served from web root. (which is as designed)

Steps to reproduce:

  1. npm run build
  2. npm install -g http-server
  3. cd dist
  4. http-server

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.

0reactions
ConstantineStehoffcommented, Jan 31, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found