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.