Skip to content

Commit 127364e

Browse files
committed
Added error handling for non-CORS requests.
1 parent 52426bc commit 127364e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/core/config/OperationConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ const OperationConfig = {
34073407
"<br><br>",
34083408
"You can add headers line by line in the format <code>Key: Value</code>",
34093409
"<br><br>",
3410-
"This operation will throw an error for any status code that is not 200, unless the 'Ignore status code' option is checked.",
3410+
"The status code of the response, along with a limited selection of exposed headers, can be viewed by checking the 'Show response metadata' option. Only a limited set of response headers are exposed by the browser for security reasons.",
34113411
].join("\n"),
34123412
run: HTTP.runHTTPRequest,
34133413
inputType: "string",

src/core/operations/HTTP.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ const HTTP = {
126126

127127
return fetch(url, config)
128128
.then(r => {
129+
if (r.status === 0 && r.type === "opaque") {
130+
return "Error: Null response. Try setting the connection mode to CORS.";
131+
}
132+
129133
if (showResponseMetadata) {
130134
let headers = "";
131135
for (let pair of r.headers.entries()) {

0 commit comments

Comments
 (0)