Skip to content

Commit

Permalink
[FIX] http: force mimetype of .js files to text/javascript
Browse files Browse the repository at this point in the history
Previously, when the odoo server was running on some Windows
installations, it was possible for javascript files loaded directly from
the static folder of an addon to fail to run because the Content-Type
header was set to text/plain instead of text/javascript. This is because
the mimetypes module from the standard library honors the mimetypes from
the OS, in the case of Windows it reads a key in the registry, which can
be misconfigured to text/plain for .js files.

This commit forces the mimetype of .js files to text/javascript to solve
this issue.

closes #162277

X-original-commit: 9474c99
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
  • Loading branch information
sdegueldre authored and Julien00859 committed Apr 17, 2024
1 parent a8ec228 commit 64cbe38
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions odoo/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
mimetypes.add_type('application/x-font-ttf', '.ttf')
# Add potentially wrong (detected on windows) svg mime types
mimetypes.add_type('image/svg+xml', '.svg')
# this one can be present on windows with the value 'text/plain' which
# breaks loading js files from an addon's static folder
mimetypes.add_type('text/javascript', '.js')

# To remove when corrected in Babel
babel.core.LOCALE_ALIASES['nb'] = 'nb_NO'
Expand Down

0 comments on commit 64cbe38

Please sign in to comment.