[FIX] http: force mimetype of .js files to text/javascript

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 odoo/odoo#162313

X-original-commit: 64cbe389e698398eee93ebde9c61b2ee79756380
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
Samuel Degueldre
2024-04-18 05:53:27 +00:00
committed by Julien Castiaux
parent 41ccb102c1
commit b258e5d294
+3
View File
@@ -200,6 +200,9 @@ mimetypes.add_type('application/x-font-ttf', '.ttf')
mimetypes.add_type('image/webp', '.webp')
# 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'