Question Form: Next.js Static Content 404 Error on VPS
Answered
Eric posted this in #help-forum
EricOP
Issue Description:
I'm currently trying to host a Next.js application on my VPS. The application is mostly functioning, but I'm encountering a specific problem with static content. While images are loading correctly, files located in
Details:
- Application Path:
- Permissions: The static files exist in their respective folders and permissions appear to be correct. (see Images)
nginx.conf Settings:
(see last Image)
I've tried adjusting configurations and permissions but haven't had any success so far. Any suggestions on what might be causing this issue or how to resolve it would be greatly appreciated)!
2024/07/05 16:02:19 [error] 3111#3111: *2 open() "/var/www/DOMAIN/dvag/_next/static/chunks/453-a28bdadbb4196965.js" failed (2: No such file or directory), client: 91.26.148.34, server: DOMAIN, request: "GET /_next/static/chunks/453-a28bdadbb4196965.js HTTP/1.1", host: "DOMAIN", referrer: "https://DOMAIN/"
I think the Problem occurs because it requests the _next folder, but Next uses the .next folder. IDK
I'm currently trying to host a Next.js application on my VPS. The application is mostly functioning, but I'm encountering a specific problem with static content. While images are loading correctly, files located in
_next/static/chunks/, _next/static/css/, and _next/static/media/ are consistently returning 404 errors. (Image: NETWORK)Details:
- Application Path:
/var/www/DOMAIN/dvag/.next- Permissions: The static files exist in their respective folders and permissions appear to be correct. (see Images)
nginx.conf Settings:
(see last Image)
I've tried adjusting configurations and permissions but haven't had any success so far. Any suggestions on what might be causing this issue or how to resolve it would be greatly appreciated)!
2024/07/05 16:02:19 [error] 3111#3111: *2 open() "/var/www/DOMAIN/dvag/_next/static/chunks/453-a28bdadbb4196965.js" failed (2: No such file or directory), client: 91.26.148.34, server: DOMAIN, request: "GET /_next/static/chunks/453-a28bdadbb4196965.js HTTP/1.1", host: "DOMAIN", referrer: "https://DOMAIN/"
I think the Problem occurs because it requests the _next folder, but Next uses the .next folder. IDK
Answered by Eric
To fix this issue, you need to create a symbolic link from .next to _next so that the server can find the necessary files. You can do this by running the following command in the terminal:
ln -s /var/www/DOMAIN/dvag/.next /var/www/DOMAIN/dvag/_next
ln -s /var/www/DOMAIN/dvag/.next /var/www/DOMAIN/dvag/_next
2 Replies
EricOP
To fix this issue, you need to create a symbolic link from .next to _next so that the server can find the necessary files. You can do this by running the following command in the terminal:
ln -s /var/www/DOMAIN/dvag/.next /var/www/DOMAIN/dvag/_next
ln -s /var/www/DOMAIN/dvag/.next /var/www/DOMAIN/dvag/_next
Answer
@Eric To fix this issue, you need to create a symbolic link from .next to _next so that the server can find the necessary files. You can do this by running the following command in the terminal:
ln -s /var/www/DOMAIN/dvag/.next /var/www/DOMAIN/dvag/_next
EricOP
Thanks! This works! You are such a nice guy!