I was using angular 6. I was building my project with this cli command:
ng build --prod --base-href=
Then, I was opening dist/index.html
directly, without a server, and in those happy days in this way I could use my project offline.
Recently I have updated angular to 8. Now, I build with the same command. However, now I get CORS error:
Access to script at 'file:///D:/...../polyfills-es2015.707fe33a73ba6b994c2b.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
What has changed? How could I use my project offline just like before?
Edit:
Now I am able to answer
"What has changed?"
Before, in index.html
, type
for script was "text/javascript"
. But now I see "module"
.
Before:
<script type="text/javascript" src="main.90ef8874f90877154126.bundle.js">
Now:
<script src="main-es2015.057f1c108bdef8198685.js" type="module">
When I convert module to text/javascript, it works.
But now I don't know what type="module"
is for, why angular, or cli, started to put "module", why Chrome does not let it, and how I can force angular to not put "module" but simply "text/javascript".