Fix UMD Build .cjs Extension Blocked Due to Incorrect MIME Type#1293
Open
eriestrisnadi wants to merge 1 commit intoianstormtaylor:mainfrom
Open
Fix UMD Build .cjs Extension Blocked Due to Incorrect MIME Type#1293eriestrisnadi wants to merge 1 commit intoianstormtaylor:mainfrom
.cjs Extension Blocked Due to Incorrect MIME Type#1293eriestrisnadi wants to merge 1 commit intoianstormtaylor:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Some browsers enforce strict Content Security Policy (CSP) or Cross-Origin Read Blocking (CORB) rules that check the MIME type of scripts. If the MIME type returned in the response headers doesn’t match the expected type for execution, the browser will block the script.
Example: JSDelivr
For instance, if you use the following snippet:
JSDelivr will serve the script with a MIME type of
application/node, which causes the browser to block it:Example: Unpkg
For instance, if you use the following snippet:
Unpkg will serve the script with a MIME type of
text/plain, which will also result in the script being blocked:Suggested Fix
To resolve this issue, we recommend using the
.jsextension instead of.cjs. Changing the extension to.jswhen bundling will ensure proper execution of the script.This change will help avoid MIME type mismatches and prevent browsers from blocking the script.