0

I have configured MacOS for nginx and deployed my react js app on it it successfully deployed and running but when i reresh any page it shows 404 not found.

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8080;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    server {
        listen       8080 default_server;
        server_name  TESTAPP;
        root  /var/www/TESTAPP;
        index index.html index.htm;      
        location / {
            root /var/www/TESTAPP/static;
            index  index.html index.htm;
            try_files $uri /index.html$is_args$args =404;
        }
    }
    include servers/*;
}

1 Answers1

0

Can you try if the following works for you?

This is what I use for my SPA.

server {
        listen 8080 default_server;

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

        server_name TESTAPP;

        location / {
                try_files $uri $uri/ =404;
        }
}
Someone Special
  • 12,479
  • 7
  • 45
  • 76