From 4c398695663bccc77dec6174d2e1e2fc944a6b08 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 25 May 2021 17:54:24 -0700 Subject: [PATCH] docs: add a note about javascript mime-types to the deployment guide (#42339) Some servers don't serve the .js files with the correnct headers. This change documents the requirement. Fixes #30835 PR Close #42339 --- aio/content/guide/deployment.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/aio/content/guide/deployment.md b/aio/content/guide/deployment.md index 8c3f2c9b40..cfe3325639 100644 --- a/aio/content/guide/deployment.md +++ b/aio/content/guide/deployment.md @@ -281,6 +281,23 @@ and to } ] +{@a mime} + +### Configuring correct MIME-type for JavaScript assets + +All of your application JavaScript files must be served by the server with the [`Content-Type` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) set to `text/javascript` or another [JavaScript-compatible MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#textjavascript). + +Most servers and hosting services already do this by default. + +Server with misconfigured mime-type for JavaScript files will cause an application to fail to start with the following error: + +``` +Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec. +``` + +If this is the case, you will need to check your server configuration and reconfigure it to serve `.js` files with `Content-Type: text/javascript`. See your server's manual for instructions on how to do this. + + {@a cors} ### Requesting services from a different server (CORS)