Monday, March 4, 2024

Re: Static assets receives 403 on digital ocean.

Just sharing the related issue has a solution in this page: https://stackoverflow.com/questions/44918725/django-301-and-403-forbidden-errors-on-my-static-files-in-production

On Sunday, January 7, 2024 at 5:13:19 AM UTC-7 ASAMOAH EMMANUEL wrote:
sudo usermod -aG simple_genius www-data
sudo chown -R :www-data /home/simple_genius/projects/personal and it worked.


Now the problem is when I set DEBUG to False, some of my static assets does not serve. I am using whitenoise to serve static assets. I am also using django-tailwind in my project. STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"



This is what is shown on the console when I inspect:
"Error
/static/css/index.5398d9d5876f.css:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
/static/css/dist/sty….7012601486cf.css:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
logo.a5ccc3546241.png:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
main.b84581c0c996.js:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
/static/sound/click.4db7b7b75cbd.wav:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
/static/sound/tick.052246d34aa1.wav:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
/static/sound/swish.af479ba9668b.m4a:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
banner.9b9fbdecaf08.png:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
index.5398d9d5876f.css:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)
Error
styles.7012601486cf.css:1 Request unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 404 (Not Found)"

On Sat, Jan 6, 2024 at 6:29 PM Ruby <dev.ru...@gmail.com> wrote:
This could be some permission-related issue, consider adding the web app user to the www-data group by running the command below

 sudo usermod -a -G "$USER" www-data

Remember to restart the web server after executing the above command.

On Sat, Jan 6, 2024 at 6:08 PM 'Ryan Nowakowski' via Django users <django...@googlegroups.com> wrote:
When you try to load one of the static assets in a separate browser tab, what content is rendered? Sometimes that gives you a hint as to why access is denied(403).


On January 3, 2024 9:02:16 PM CST, ASAMOAH EMMANUEL <emmanuela...@gmail.com> wrote:
Hi, please help. I have been trying to deploy my App to digital ocean but after deploying, my static assets do not show. I have set file and directory permissions but still in vain. this is what outputs when inspecting the browser console. help would be highly appreciated: Error
logo.png:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)
6
Unchecked runtime.lastError: The message port closed before a response was received.
Error
styles.css:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)
Error
index.css:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)
Error
main.js:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)
Error
reload-listener.js:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)
Error
/static/sound/click.wav:1 Request unavailable in the network panel, try reloading the inspected pageRequest unavailable in the network panel, try reloading the inspected page Failed to load resource: the server responded with a status of 403 (Forbidden)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/E67EA63B-4611-4323-88E7-98A013BC793D%40fattuba.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07bf7894-3951-448b-8a9c-aa6cf3ccfd34n%40googlegroups.com.

No comments:

Post a Comment