I have a backend node.js application(system directory) and a frontend react application(admin directory). I use nginx as the webserver.
I can load my frontend well. But when I refresh, it gives 404. I have looked in the nginx directives, but I'm not sure how it works, since I didn't setup this project. I know that react uses the react-router, which nginx is not aware of.
My nginx conf file is:
server {
listen 80;
server_name lcl.notification.com;
root /home/development/www/notifications/system/public;
access_log /var/log/nginx/notify.access.log;
error_log /var/log/nginx/notify.error.log debug;
rewrite_log on;
client_max_body_size 10M;
location / {
return 301 https://www.google.com;
break;
}
location /panel {
alias /home/development/www/notifications/admin/build/;
index index.html;
try_files $uri $uri/ =404;
# Include headers
include includes/headers.conf;
}
After login, it opens the /panel uri. But on refresh, it gives 404.