Skip to content

Commit ba31b55

Browse files
authored
docs: add cross-origin script error details (#1249) (#1250)
1 parent 6f4aa3a commit ba31b55

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/troubleshooting.asciidoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@ further to identify the offending code.
1414
Of course, there are errors that might have been caused by the agent itself and we appreciate it if
1515
you <<get-in-touch, report them back to us>>.
1616

17+
[float]
18+
[[cross-origin-script-error]]
19+
=== Some errors in the application only show `script error`
20+
In some cases when you look at the details of an error, the only information you can see is the message `Script error`.
21+
This happens when an error originates from a JavaScript file served from a different origin than the page's origin.
22+
23+
In order to get visibility of the error's detail, you must do two things.
24+
25+
1. Add the attribute `crossorigin` to the `<script>` element:
26+
+
27+
[source,js]
28+
----
29+
<script src="https://example.com/example.js" crossorigin>
30+
----
31+
32+
2. Make sure that the server response includes the `Access-Control-Allow-Origin` header when serving the JavaScript file.
33+
+
34+
[source,js]
35+
----
36+
// Either of the two values is valid:
37+
38+
Access-Control-Allow-Origin: *
39+
Access-Control-Allow-Origin: your page's origin
40+
----
41+
42+
TIP: To learn more about how browsers handle script errors, see the MDN page on the https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#notes[onerror] event.
43+
1744

1845
[float]
1946
[[no-stack-trace-available]]

0 commit comments

Comments
 (0)