Nasty safety

Can’t program a page because of fanatic security settings which i was unable to disable.
I am trying to make a simple starting project for react, the scripts are included using unpkg, but as always some problems out of nowhere has to pop up.

this is the script:

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>

<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>

<script crossorigin src="https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js"></script>
<div id="test"></div>

<script type="text/babel">

           ReactDom.render(<h1>Abcd, </h2>, document.getElementById("test"));

</script>

And these are the errors:

The resource from “https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js. (Reason: CORS request did not succeed). Status code: (null).

The resource from “https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js. (Reason: CORS request did not succeed). Status code: (null).

source URI is not allowed in this document: “https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js”. [index.html:10:1](http://127.0.0.1:5500/index.html) Live reload enabled. I am not wasting my time on randomness, so whoever made it this way should probably now spend his time to fix it, there are many topics struggling with this nonsense, but no clear solution how to fix it (some people suggested to disable some plugins which i don't have), i already lost 2h and no one know ANYTHING how to practically disable this nasty thing, there was 1 answer which suggested to disable the security in the starting parameters of the app, but this from what was said later this doesn't work and it was made for chrome...

@dragontiger355 I’m sorry you’re having issues getting your starting project working. I think you’ve been misled by the security warnings. unpkg.com is allowed for other resources like https://unpkg.com/react@16/umd/react.production.min.js, but not https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js. You may already see the issue, but you should focus on the first error before looking at later ones:

The resource from “https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js” 1 was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

This means the website was serving HTML (MIME type ("text/html")) instead of Javascript (text/javascript).

I visited
https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js and indeed got an HTML page that displays the minified source. However, you want just the JS source code.

Change your code from:

<script crossorigin src="https://unpkg.com/browse/babel-standalone@6.26.0/babel.min.js"></script>

to

<script crossorigin src="https://unpkg.com/babel-standalone@6.26.0/babel.min.js"></script>

(which you can get by clicking “RAW”)

I hope this helps your programming issue. There is one other issue…

Programming is difficult. After over 20 years of software development, I still lose two hours (and sometimes two days) trying to figure out why my code is broken. 95% of the time, it is because I made a mistake in my code. Often, asking someone else to look at my code is a great strategy, and they can see the problem that I’m ignoring. However, if you start with anger and blaming, people are less likely to help. Stay humble, make many small changes, and test and verify.

Good luck with your journey! - John

1 Like