mudgen
(Nick Mudge)
July 16, 2020, 9:18pm
1
1. Caddy version (caddy version
):
Version: v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
2. How I run Caddy:
caddy run
a. System environment:
Windows 10
b. Command:
caddy run
c. Service/unit/compose file:
Not applicable.
d. My complete Caddyfile or JSON config:
localhost
root * ./src
file_server
3. The problem I’m having:
When caddy runs and I go to localhost I get the following error in my Chrome web browser console:
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.
So it seems Caddy is giving the wrong MIME type for my Javascript file. It should give application/javascript
.
What can I do?
matt
(Matt Holt)
July 16, 2020, 9:21pm
2
What is the request that is being made?
mudgen
(Nick Mudge)
July 16, 2020, 9:38pm
3
Here are the request headers from Chrome:
:authority: localhost
:method: GET
:path: /app.js
:scheme: https
accept: /
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
origin: https://localhost
pragma: no-cache
referer: https://localhost/
sec-fetch-dest: script
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
The script is being retrieved by an index.html file with this in it:
<script src="app.js" type="module" ></script>
mudgen
(Nick Mudge)
July 16, 2020, 10:02pm
4
How else can I help you help me?
2 Likes
matt
(Matt Holt)
July 16, 2020, 10:27pm
5
Welcome Nick! We appreciate that
Your config works for me, with the main difference being that I don’t use Windows – does Windows have some sort of system MIME types file that the Go standard lib can load its file associations from?
1 Like
On linux, it’s often because the mailcap
package is missing which provides the MIME type lookup tables.
It looks like this is the code that fetches them for Windows, looks like it gets them via a syscall to the registry.
I’m not sure what’s going on
mudgen
(Nick Mudge)
July 16, 2020, 11:11pm
7
2 Likes
matt
(Matt Holt)
July 16, 2020, 11:15pm
8
Fascinating! Thanks for looking into it, and for explaining the fix. I’m sure it will help others searching for the same problem.
1 Like
system
(system)
Closed
August 15, 2020, 9:20pm
9
This topic was automatically closed after 30 days. New replies are no longer allowed.