oidc-client: The script has an unsupported MIME type ('text/html'). DOMException: Failed to register a ServiceWorker
Issue and Steps to Reproduce
When loading framework libraries “The script has an unsupported MIME type (‘text/html’).” is written to console.
When accessing <OidcSecure> protected React component error happen. And page is displayed: “Authentification erreur Une erreur est survenu lors de l’authentification”
This happens only if I’m using:
service_worker_relative_url:'/helpers/authentication/OidcServiceWorker.js',
service_worker_only:true
in oidcConfiguration. Without ServiceWorker everything is fine.
I want to use service worker as a event entry point after login/silentLogin to update user context with name of logged user. (i dont want to create authentication/callback page and do it there)
Versions
4.2.8
Screenshots
Expected
Redirect to oidc authentication endpoint.
Actual
Error is displayed.
Additional Details
Has anyone run into this issue since migration v3 -> v4? I’ve done all steps according to the manual. And I’m getting this error.
- Installed packages: “@axa-fr/react-oidc-context”: “^4.2.8”, “react”: “17.0.2”, “react-dom”: “17.0.2”
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (12 by maintainers)
Thank you for your feeback 😃
it was merge on main branch => https://github.com/AxaGuilDEv/ml-cli/blob/master/src/Ml.Cli.WebApp/ClientApp/public/web.config
😃
May we close that issue?
Thanks a lot for you response! For the first issue, you’re absolutely right. It seems to be the CORS problem in my code.
Regarding the updating UserInfo: I only need to read UserInfo, not modify it. This will happen in my custom function. The thing is that I need event, that will trigger when the user is authenticated either from normal or silent callback. Just as a trigger for my functions to update context. 😃
Once again, thanks a lot!
Hi @Mastanka , Thank you for your issue,
About your first message, it is routing server configuration problem, because your are inside a SPA (or may be CORS problem that hide the real message).
Look the content of the response of the/helpers/authentication/OidcServiceWorker.js it migth be your index.htm or something else.
Here is an example web.config file that i use in order to make server routing work on Azure WebApp => https://github.com/AxaGuilDEv/ml-cli/blob/feature/auth/src/Ml.Cli.WebApp/ClientApp/public/web.config
Regards,