Skip to content

Commit a31e633

Browse files
committed
fix: lazy-load xmlhttprequest
1 parent 5e019c8 commit a31e633

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/ws-kernel-picker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import isEmpty from "lodash/isEmpty";
55
import tildify from "tildify";
66
import { v4 } from "uuid";
77
import ws from "ws";
8-
import { XMLHttpRequest as NodeXMLHttpRequest } from "xmlhttprequest"; // TODO use @aminya/xmlhttprequest
98
import { URL } from "url";
109
import { Kernel, Session, ServerConnection } from "@jupyterlab/services";
1110
import Config from "./config";
@@ -198,7 +197,9 @@ export default class WSKernelPicker {
198197
options.requestHeaders.Cookie = cookie;
199198

200199
options.xhrFactory = () => {
201-
const request = new NodeXMLHttpRequest();
200+
// we use xmlhttprequest because it allows disabling header protection
201+
const { XMLHttpRequest } = require("xmlhttprequest"); // TODO use @aminya/xmlhttprequest
202+
const request = new XMLHttpRequest();
202203
// Disable protections against setting the Cookie header
203204
request.setDisableHeaderCheck(true);
204205
return request as XMLHttpRequest; // TODO fix the types

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
"mobx-react": false,
160160
"@nteract/plotly": false,
161161
"refractor": false,
162-
"highlight.js": false
162+
"highlight.js": false,
163+
"xmlhttprequest": false
163164
},
164165
"isLibrary": true
165166
}

0 commit comments

Comments
 (0)