nest-graph-inspector 0.8.0-test.3 → 0.8.0-test.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,7 @@ export declare class ProxyAdapter implements ProxyGateway {
|
|
|
13
13
|
private createProxyRequestOptions;
|
|
14
14
|
private handleProxyError;
|
|
15
15
|
private getRequestModule;
|
|
16
|
+
private clearDefaultCorsHeaders;
|
|
16
17
|
private getCorsHeaders;
|
|
17
18
|
private applyCors;
|
|
18
19
|
private handleCorsPreflight;
|
|
@@ -30,6 +30,7 @@ let ProxyAdapter = class ProxyAdapter {
|
|
|
30
30
|
type: '*',
|
|
31
31
|
path,
|
|
32
32
|
rawCallback: (clientReq, clientRes) => {
|
|
33
|
+
this.clearDefaultCorsHeaders(clientRes);
|
|
33
34
|
if (this.handleCorsPreflight(cors, clientReq, clientRes)) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
@@ -101,6 +102,15 @@ let ProxyAdapter = class ProxyAdapter {
|
|
|
101
102
|
getRequestModule(targetUrl) {
|
|
102
103
|
return targetUrl.protocol === 'https:' ? node_https_1.default : node_http_1.default;
|
|
103
104
|
}
|
|
105
|
+
clearDefaultCorsHeaders(res) {
|
|
106
|
+
res.removeHeader('Access-Control-Allow-Origin');
|
|
107
|
+
res.removeHeader('Access-Control-Allow-Methods');
|
|
108
|
+
res.removeHeader('Access-Control-Allow-Headers');
|
|
109
|
+
res.removeHeader('Access-Control-Allow-Credentials');
|
|
110
|
+
res.removeHeader('Access-Control-Expose-Headers');
|
|
111
|
+
res.removeHeader('Access-Control-Max-Age');
|
|
112
|
+
res.removeHeader('Vary');
|
|
113
|
+
}
|
|
104
114
|
getCorsHeaders(cors, req) {
|
|
105
115
|
if (!cors)
|
|
106
116
|
return {};
|
|
@@ -94,10 +94,17 @@ let ViewerOutputAdapter = class ViewerOutputAdapter {
|
|
|
94
94
|
return { origin, path };
|
|
95
95
|
}
|
|
96
96
|
viewerCorsOptions() {
|
|
97
|
+
const viewerUrl = new URL(this.viewerBaseUrl);
|
|
98
|
+
const viewerOrigin = viewerUrl.origin;
|
|
97
99
|
return {
|
|
98
|
-
origins:
|
|
100
|
+
origins: this.isLoopbackHost(viewerUrl.hostname)
|
|
101
|
+
? [viewerOrigin, /^https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/]
|
|
102
|
+
: [viewerOrigin],
|
|
99
103
|
};
|
|
100
104
|
}
|
|
105
|
+
isLoopbackHost(hostname) {
|
|
106
|
+
return (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]');
|
|
107
|
+
}
|
|
101
108
|
async writeHistoryFiles(dirPath, trace) {
|
|
102
109
|
const traceIndex = this.runtimeTraceRecorder
|
|
103
110
|
.getCompletedTraces()
|