I'm having difficulties implementing something simple: I have an index.html file served on http://localhost:3200 by ruby on rails, which uses a javascript file served on http://localhost:8000 by webpack-dev-server.
So here's what I have:
<!doctype html>
<head>
<script crossorigin="anonymous" src="http://localhost:8000/app.js" />
</head>
<!-- ... -->
</html>
My app.js file is sent with, amongst others, the following header:
Access-Control-Allow-Origin: *
What I want is to be able to override window.onerror
in app.js, and see caught errors, rather than "Script error".
What am I missing?
-- edit -- Since it might not be clear enough: my script does load. I have no problem with that. My issue is that I need to report errors that happen to somewhere else, but I can't do that since any error that occurs in app.js is reported as "Script error" rather than something more explicit.
I'm having difficulties implementing something simple: I have an index.html file served on http://localhost:3200 by ruby on rails, which uses a javascript file served on http://localhost:8000 by webpack-dev-server.
So here's what I have:
<!doctype html>
<head>
<script crossorigin="anonymous" src="http://localhost:8000/app.js" />
</head>
<!-- ... -->
</html>
My app.js file is sent with, amongst others, the following header:
Access-Control-Allow-Origin: *
What I want is to be able to override window.onerror
in app.js, and see caught errors, rather than "Script error".
What am I missing?
-- edit -- Since it might not be clear enough: my script does load. I have no problem with that. My issue is that I need to report errors that happen to somewhere else, but I can't do that since any error that occurs in app.js is reported as "Script error" rather than something more explicit.
Share Improve this question edited Jan 14, 2020 at 6:00 sideshowbarker♦ 88.6k30 gold badges215 silver badges212 bronze badges asked Feb 1, 2017 at 14:43 Nicolas SEPTIERNicolas SEPTIER 8511 gold badge10 silver badges20 bronze badges 14- 1 There's no need for CORS headers when loading scripts. – Pointy Commented Feb 1, 2017 at 14:46
-
Remove the
crossorigin
property in thescript
tag. By default scripts don't have single origin restriction. Thecrossorigin
property was added to enable people to enforce CORS restriction. So unless you want to block script loading form foreign urls you should removecrossorigin
property form the script tag. – slebetman Commented Feb 1, 2017 at 14:54 -
I'm just trying to fix an issue following what I can see everywhere, like on this page: raygun./blog/2015/05/fixing-script-errors. Removing the
crossorigin
attribute doesn't solve my problem either, unfortunately. – Nicolas SEPTIER Commented Feb 1, 2017 at 14:56 - So redefine window.onerror.... – epascarello Commented Feb 1, 2017 at 15:04
- Well webpack puts all of the scripts into one file. And you do not like the fact it points to that file? – epascarello Commented Feb 1, 2017 at 15:09
2 Answers
Reset to default 8What sourcemap (devtool) are you using?
I was getting this issue, and it changing from eval-source-map
to source-map
fixed it.
This is a google chrome issue, should be when Chrome 71 is released.
Here are the relevant issue threads:
https://bugs.chromium/p/chromium/issues/detail?id=765909
https://github./webpack/webpack/issues/5681
Edit: This also impacts electron users.