-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: add built-in mime type for *.mjs #30547
Comments
Is there an official spec that's proposing standardizing that mime type for that extension? (something more formal that the page you linked) |
That's a good question. Mime
mjs ExtensionI did not find anything "official", other than common usage:
|
With #31327 landed perhaps this should go in, too. |
Sure. Send a change. Makes sense to also do it in Go 1.13 to match #31327. |
Looks like it was already done in https://golang.org/cl/169502 Closing :) |
It looks like the mime type added was It is my understanding the mimetype should therefore be Nevertheless, it is great to hear that the mimetype was added! |
@dkumor, I sent a fix. Thanks. |
Change https://golang.org/cl/175459 mentions this issue: |
.mjs should be the same MIME type as .js, and RFC 4329 says that text/javascript is obsolete, even back in 2006: https://tools.ietf.org/html/rfc4329#section-7.1 I didn't notice this when I recently reviewed CL 169502. Also, re-sort it. Updates #30547 Change-Id: I8ed8ddaf06c8a08b010423ebd071f39ef3a325e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/175459 Reviewed-by: Andrew Bonventre <[email protected]> Run-TryBot: Andrew Bonventre <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Given a folder with the following files:
index.html:
and test.mjs (see: https://developers.google.com/web/fundamentals/primers/modules)
My code serves the above with
http.FileServer
, and I navigate to/
in my browser, openingindex.html
What did you expect to see?
I expected
hi
to be printed in the javascript consoleWhat did you see instead?
The following error in chrome:
This is because
.mjs
is not a recognized mimetype. This can easily be worked around by manually adding.mjs
to the mime database:Or, technically, one can just use
.js
- but.mjs
seems to be commonly used.However, since es modules are a standard, and will become more common in the future, it would be nice to have the mimetype built in.
The text was updated successfully, but these errors were encountered: