0

I am currently creating a Django + React application. I am currently using React 18.2.0 and Django 4.2. I have my application completed when Debug=True in Django. However, once I perform the operation:

DEBUG = False

ALLOWED_HOSTS = ["*"]

The website breaks once I change these lines of code. When I look into the console in the website it displays the error:

Refused to execute script from 'http://localhost:8000/static/js/main.94957794.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

I got three of these errors each depending on if it was a stylesheet or javascript. After a few hours of tinkering around I manage to figure out that the problem was with some libraries that I am using from npm (react-animation, Animate.css and countries-list). React Animation is an out-of-date library and had to downgrade to React 16.8.0. (Idk if that is a possible reason). How would I solve these errors?

I am just very confused as the website works when DEBUG = True but not when DEBUG = False.

My main problem is that the website just doesn't work altogether when I set DEBUG = False.

Does anyone have a solution to this?

I have tried many different ways of solving it, like trying different versions of React and using different libraries, but I still get the same error of MIME type ('text/html') is not executable.

newtinn
  • 17
  • 3
  • 1
    Does this answer your question? [Why does DEBUG=False setting make my django Static Files Access fail?](https://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail) – Ivan Starostin Jun 19 '23 at 06:39
  • 1
    What web server are you using? The web server is in charge to serve your static files (incl. your javascript files!). It looks like within the configuration of your web server you did not add the MIME types. Please add this info to your question in case linked question above did not already solve your issue. – Tarquinius Jun 20 '23 at 09:49

0 Answers0