Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

mimetype error django react

Upon deploying the web app in Heroku, one of the common issues that occur 
is the static files failing to load due to MIME type limitations. 
The particular MIME type (text/html) problem is related
to your Django configuration.

The views.py in your React frontend needs 
a content_type argument in the HttpResponse.
Heroku needs to know where the static files are.

The "refused to execute script ... MIME type ('text/html')" problem 
stems from Django's default content_type setting for an HttpResponse, 
which is text/html.

This can be fixed by including a content_type='application/javascript' 
argument in the return statement of a 
new class-based view called Assets(View) inside views.py like so:

for more info visit:
https://dev.to/mdrhmn/deploying-react-django-app-using-heroku-2gfa
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #mimetype #error #django #react
ADD COMMENT
Topic
Name
6+9 =