misleading error when wrong MIME type returned
syonip opened this issue · comments
I created a Vue CLI 3 app with the PWA plugin, and followed instructions to test locally by serving the dist
directory with a simple http server.
When I used the python's SimpleHTTPServer, I received the error: Error during service worker registration: Error: Service worker not found at ./service-worker.js
.
This was misleading because the file was indeed served successfully. Had to debug the module to find that the content type wasn't returned as text/javascript
by the python server.
I suggest emitting a more precise error in this case.
I'm happy to PR.
If the client-side thrown error actually contains information indicating it's about wrong MIME type, then yes. But I doubt it.
I think the culprit is this line:
if ( response.status === 404 || response.headers.get('content-type').indexOf('javascript') === -1 )
I saw that indeed response.status is 200, so we can split the conditions and in the second case emit another error. What do you think?
Yeah, that makes sense
Great, I will make a PR soon