Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying to production with nginx #36

Closed
archienorman11 opened this issue Aug 14, 2018 · 1 comment
Closed

Deploying to production with nginx #36

archienorman11 opened this issue Aug 14, 2018 · 1 comment

Comments

@archienorman11
Copy link

archienorman11 commented Aug 14, 2018

Hi - I am unable to deploy my react application to production.

I can run the app locally with no problems. I then run:

npm run build

Push the bundled code to my server and configure nginx

server {
        listen       80;
        server_name  *;

        #access_log  /var/logs/nginx/nginx_access.log;
        #error_log  /var/logs/nginx/nginx_error.log;

        root /var/www/;
        index index.html;

        # Any route that doesn't have a file extension (e.g. /devices)
        location / {
            try_files $uri $uri/ /index.html;
        }
    }

I can see the plaintext in my browser when I run the application (via docker), the static files load, but they do not render correctly.

Here is an example of an image import:

<img class="waiting_icon" src="./static/media/waiting.da817564.svg" alt="logo">

Nothing shows, same with css styling.

Any suggestions - thanks.

Update:

I am importing the css in /src/index.js like so:

import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import store, { history } from './store';
import App from './containers/app';

import './index.css';
@archienorman11 archienorman11 changed the title Deploying after build with nginx Deploying to production with nginx Aug 14, 2018
@notrab
Copy link
Owner

notrab commented Aug 15, 2018

Hi @archienorman11

Are you serving the build folder? I've no experience with nginx but I'd suggest you post this over on StackOverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants