GoogleChromeLabs / simplehttp2server

A simple HTTP/2 server for development
Other
1.74k stars 98 forks source link

script has an unsupported MIME type ('text/plain') #41

Open claytoncarney opened 5 years ago

claytoncarney commented 5 years ago

Trying to use simplehttp2server as a development server to conduct Lighthouse testing. It is not working because the server is setting content-type for javascript files to 'text/plain' rather than ​'application/javascript'. As a result, the service worker fails to load. How could this issue be resolved?

claytoncarney commented 5 years ago

OK, got the javascript issue resolved with this config file:

{
  "hosting": {
    "redirects": [
      {
      "source": "http://localhost:5000",
      "destination": "https://localhost:5000",
      "type": 301
      }
    ],
    "headers": [
      {
        "source": "**/*.@(js)",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/javascript"
          }
        ]
      } 
    ]
  }
}

However, this revealed another Lighthouse issue: redirect http traffic to https. Nothing I've tried works; any http request results in an error:

TLS handshake error from [::1]:50500: read tcp [::1]:5000->[::1]:50500: use of closed network connection

How can this issue be resolved?