I’ve deployed a React app on my server and am using Nginx to serve the static files. The frontend is being served using http-server on port 5000, and Nginx is configured to proxy requests to that port. I can see the latest updates when I access the app using the server’s IP (http://:5000), but the changes are not reflected when I access the app via the domain (https://).
Here’s what I’ve done so far:
I ran npm run build and confirmed the build files are up-to-date in the /var/www//frontend/build directory.
I configured Nginx to serve the static files from the build/ directory and proxy API requests to localhost:5001.
Nginx is listening on port 443 for HTTPS traffic.
I restarted Nginx and cleared the browser cache, but still, the changes are not visible on the domain.
I can see the correct files loading from the IP address, but not from the domain.
Nginx Configuration:
nginx
server {
server_name <your-domain>;
root /var/www/<your-site>/frontend/build;
index index.html;
location / {
try_files $uri /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
location /api/ {
proxy_pass http://localhost:5001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/<your-domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<your-domain>/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
listen 80;
server_name <your-domain>;
return 301 https://$host$request_uri;
}
Things I’ve tried:
Restarting Nginx and PM2.
Clearing my browser cache and using Incognito mode.
Checking the file timestamps to confirm the build folder is up-to-date.
Any ideas on what could be causing this discrepancy? Why do the updates show up when accessing the app via the IP but not the domain?