I am trying to deploy a React application in a subfolder on my Nginx server.
The location of this React app is structured like: www.example.com/reactApp.
I tried to set up my current nginx.conf like so:
server {
..other configs..
location /reactApp {
root /var/www;
index reactApp/index.html;
try_files $uri $uri/ /index.html;
}
..other configs..
}
This has not worked. What do I need to change to fix my subfolder routing?
The last component of the try_files
statement should be a URI. Assuming that your index.html
file is located under the /var/www/reactApp
subfolder, you should use:
location /reactApp {
root /var/www;
index index.html;
try_files $uri $uri/ /reactApp/index.html;
}
See this document for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With