ServiceWorker script has an unsupported MIME type — how do I fix registration?

The service worker registration requested a script and received an unsupported media type. Check the exact URL passed to register(). A catch-all route may return the application HTML, or the server may label the real script as text/plain.
Inspect both the response and any redirect. Publish the worker file at the expected path and configure the server to return a valid JavaScript media type. Make sure the request does not land on a login or fallback page.
curl -I https://example.com/sw.js
A header probe can return 200 even when sw.js is served by an HTML fallback. Read the browser response before changing the media type. After the correct worker script arrives, check the registration state in DevTools.
Open the exact worker registration URL and verify that it returns the worker source and a JavaScript Content-Type.