I want to use Polymer LitElement with a Go backend. With LitElement I implement the web components in JavaScript modules! For routing on the server-side I use Gorilla Mux like this
mux := mux.NewRouter()
mux.PathPrefix("/").Handler(http.FileServer(http.Dir("./wwwroot")))
This loads static html files correctly. When a html file references a js file that implements a web component I get the following error (in Chrome):
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.
When I rename my component module to have the extension mjs the file loads correctly but then the module for LitElement fails to load with the same error. Since I have no influence on the file extensions of all third party JavaScript modules I don't know how to fix this.
(I guess I would experience the same problems if I were using Polymer 3 instead of LitElement)
Any ideas?
Update
Here is the output from requesting the lit-element.js JavaScript module with curl
PS C:\Test\Polymer\LitElement> curl http://localhost:8082/node_modules/lit-element/lit-element.js
StatusCode : 200
StatusDescription : OK
Content : /**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* Th...
RawContent : HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 8925
Content-Type: text/plain; charset=utf-8
Date: Thu, 26 Sep 2019 11:38:23 GMT
Last-Modified: Sat, 26 Oct 1985 08:15:00 GMT
/**
* @licen...
Forms : {}
Headers : {[Accept-Ranges, bytes], [Content-Length, 8925], [Content-Type, text/plain; charset=utf-8], [Date,
Thu, 26 Sep 2019 11:38:23 GMT]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 8925
Notice the Content-Type!!!