Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIME of .mjs files #2253

Closed
benedictdudel opened this issue Mar 21, 2023 · 7 comments
Closed

MIME of .mjs files #2253

benedictdudel opened this issue Mar 21, 2023 · 7 comments

Comments

@benedictdudel
Copy link

Unfortunately skipper is serving .mjs files as application/octet-stream instead of application/javascript. The MIME used to identify .mjs files should be a web compatible JavaScript MIME Type.

Does anyone has a workaround to set the correct Content-Type header for *.mjs files with skipper in the meantime?

@AlexanderYastrebov
Copy link
Member

Hello, how do you serve these files? Could you provide an example route maybe?

@benedictdudel
Copy link
Author

@AlexanderYastrebov Unfortunately I have no public route available. I stumbled across the issue with the new storybook version which uses .mjs files. Here is the corresponding issue in Storybook with some more context (albeit using nginx).

@benedictdudel
Copy link
Author

Here is some more context regarding to updates to ECMAScript media types.

@AlexanderYastrebov
Copy link
Member

If we are talking about static filter then it uses https://pkg.go.dev/net/http#FileServer which internally uses https://pkg.go.dev/mime#TypeByExtension which relies on system mime files (see docs):

~$ grep mjs /usr/share/mime/globs2 
50:application/javascript:*.mjs

~$ mkdir /tmp/skipper2253
~$ echo "This is an .mjs file" > /tmp/skipper2253/test.mjs
~$ bin/skipper -inline-routes='* -> static("/tmp/skipper2253") -> <shunt>'

~$ curl -v localhost:9090/test.mjs 2>&1 | grep Content-Type
< Content-Type: text/javascript; charset=utf-8

@AlexanderYastrebov
Copy link
Member

AlexanderYastrebov commented Mar 21, 2023

Actually mjs seems to be hardcoded which explains the result discrepancy (application/javascript vs text/javascript) in #2253 (comment)

@AlexanderYastrebov
Copy link
Member

See related golang/go#32351

@benedictdudel
Copy link
Author

Thank you for your fast response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants