I have a server which points to a DNS ‘ahammed.online’. Currently, I have a backend server running on it. I need to deploy the react front end as well to this server. For that, I have a build file and I kept this file in the directory,
/var/www/ahammed.onine/html/pdfManager/dist/index.html
CSS and JS files are located in the /dist/assets/ folder.
My index.html is accessible by calling the route ahammed.online/pdfManager, but my CSS and JS files are not accessible. They are throwing a 404 error. the route request is going like this
ahammed.online/assets/fsjdlfj 34.j and ahammed.online/assets/fsfjsdljfsd.css
How can I correctly configure NginX for this? I can not configure /location/asssets{} as I need to host a portfolio in this same server under the router ahammed.online/portfolio
My current config file is located at /etc/nginx/sites-available/ahammed.online
To send the static build file.
server{
root /var/www/ahammed.online/html;
index index.html index.htm index.nginx-debian.html;
location /pdfManager {
alias /var/www/ahammed.online/html/pdf-manager/dist/;
try_files $uri $uri/ /index.html;
}
}
When a request comes as ahammed.online/pdfManager My index file is rendered, but the CSS and JS is showing can to GET 404. relative to index file CSS and JS files are located as follows
./assets/fsdf.js