Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

refreshing page showing 404 error using Nginx [duplicate]

Hi I uploaded my react app on server and make it live. It's working fine but whenever I refresh any page of application. it's returning 404 error. what should I do ?


1 Answers

When your app load. The react-router handle Router. The Route change is handled by Router itself but on refreshing the request goes to nginx where that specific route doesn't exist.

To resolve this issue you need to load root file. try this solution.

cd /etc/nginx/sites-available
sudo nano default

in default file update location

location {
    try_files $uri /index.html;
}
like image 59
ijaz khan Avatar answered May 24 '26 22:05

ijaz khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!