Styles aren't showing up in my django webapp

yacinelaribiTRIAL

10 months ago

So basically my settings.py and configuration is correct , i worked with railway multiple times and it was working just fine ...

But now in this project when the website loads this error is appearing in the console :

Refused to apply style from 'https://hippo.yacinelaribi.site/static/css/main.css/' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

btw when i access that url locally raw text of the css shows up , but on the server it just shows me the default page of url not found ...

Please help me !

3 Replies

10 months ago

Hey, Looks like you have solved this, care to share what the issue was?


yacinelaribiTRIAL

10 months ago

Yess , apparently when you put DEBUG = False in django it will treat your media urls and static urls as if they're html pages , SO you have to use whitenoise to manage staticfiles for you (whitenoise is basically a package with simple config that compress you static files and manage serving them in production) , and for the media files you'll have to configure some cloud to serve it like Amawon S3 or Nginx Server (i'm not sure if we can do that here in railway) , Hope that helps !


10 months ago

Thank you for the explanation, glad you were able to solve this!


Styles aren't showing up in my django webapp - Railway Help Station