0

Hello i have problem with my Django React project .. i have 403 error on static files(js, css)..Error 403 NGINX Django

config ->

server {
server_name thewatchesmania.com www.thewatchesmania.com;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
    root /home/user/pyapps/The-Watches-Mania/static;
}

location /media/ {
    root /home/user/pyapps/The-Watches-Mania;
}

location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
}
stackuser
  • 1
  • 1
  • My Nginx settings uses `alias /file/to/static;` instead of `root` ..so give that a shot.. I think they both handle paths differently, but cba to figure it out: https://stackoverflow.com/questions/10631933/nginx-static-file-serving-confusion-with-root-alias **Edit** or try removing the following slash in `location /static/` -> `location /static` – Nealium Oct 18 '22 at 18:02

1 Answers1

0

If your static folder is in the root of your project folder, I think the static location on nginx.conf should be like:

location /static/ {
    root /home/user/pyapps/The-Watches-Mania;
}

Or if it's inside your main app, it will be like:

location /static/ {
    root /home/user/pyapps/The-Watches-Mania/your_main_app;
}