I am currently using VueJS for my frontend with Keycloak handling authentication, along with Webpack to bundle my code. Upon the initial application load, if the user is not authenticated, they are redirected to the Keycloak page.
During this process, an error occurs where the browser blocks the resource from "https://auth.xyz.com/auth/..." due to a MIME type mismatch (X-Content-Type-Options: nosniff). This happens because the browser is attempting to load my bundled .js files which require type=text/javascript
, but since the redirect sends them to the login page, it serves content as type=text/html
.
The only workaround currently is for the user to directly access the login page, log in, and then return to my application once authenticated for it to load correctly.
As I am new to Webpack, I am seeking guidance on how to resolve this issue. Is there a way to configure Webpack to accept both HTML and JavaScript when trying to access my application's resources?