@@ -111,65 +111,53 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
111
111
===================================================================
112
112
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
113
113
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
114
- @@ -271,16 +271,15 @@ export class WebClientServer {
115
- return void res.end();
116
- }
114
+ @@ -246,7 +246,9 @@ export class WebClientServer {
115
+ };
116
+
117
+ // Prefix routes with basePath for clients
118
+ - const basePath = getFirstHeader('x-forwarded-prefix') || this._basePath;
119
+ + const rootBase = relativeRoot(getOriginalUrl(req))
120
+ + const vscodeBase = relativePath(getOriginalUrl(req))
121
+ + const basePath = vscodeBase || getFirstHeader('x-forwarded-prefix') || this._basePath;
122
+
123
+ const queryConnectionToken = parsedUrl.query[connectionTokenQueryName];
124
+ if (typeof queryConnectionToken === 'string') {
125
+ @@ -285,10 +287,14 @@ export class WebClientServer {
126
+ };
117
127
118
- - const getFirstHeader = (headerName: string) => {
119
- - const val = req.headers[headerName];
120
- - return Array.isArray(val) ? val[0] : val;
121
- - };
122
- -
123
128
const useTestResolver = (!this._environmentService.isBuilt && this._environmentService.args['use-test-resolver']);
124
129
+ // For now we are getting the remote authority from the client to avoid
125
130
+ // needing specific configuration for reverse proxies to work. Set this to
126
131
+ // something invalid to make sure we catch code that is using this value
127
132
+ // from the backend when it should not.
128
- const remoteAuthority = (
133
+ let remoteAuthority = (
129
134
useTestResolver
130
135
? 'test+test'
131
136
- : (getFirstHeader('x-original-host') || getFirstHeader('x-forwarded-host') || req.headers.host)
132
137
+ : 'remote'
133
138
);
134
139
if (!remoteAuthority) {
135
140
return serveError(req, res, 400, `Bad request.`);
136
- @@ -307,8 +306,12 @@ export class WebClientServer {
137
- scopes: [['user:email'], ['repo']]
138
- } : undefined;
141
+ @@ -335,6 +341,7 @@ export class WebClientServer {
139
142
140
- + const base = relativeRoot(getOriginalUrl(req))
141
- + const vscodeBase = relativePath(getOriginalUrl(req))
142
- +
143
143
const productConfiguration = {
144
144
codeServerVersion: this._productService.codeServerVersion,
145
- + rootEndpoint: base ,
145
+ + rootEndpoint: rootBase ,
146
146
embedderIdentifier: 'server-distro',
147
147
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
148
148
...this._productService.extensionsGallery,
149
- @@ -337,7 +340,7 @@ export class WebClientServer {
150
- folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
151
- workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
152
- productConfiguration,
153
- - callbackRoute: this._callbackRoute
154
- + callbackRoute: vscodeBase + this._callbackRoute
155
- };
156
-
157
- const cookies = cookie.parse(req.headers.cookie || '');
158
- @@ -354,9 +357,11 @@ export class WebClientServer {
159
- const values: { [key: string]: string } = {
160
- WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
149
+ @@ -382,7 +389,9 @@ export class WebClientServer {
161
150
WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
162
- - WORKBENCH_WEB_BASE_URL: this._staticRoute,
163
- + WORKBENCH_WEB_BASE_URL: vscodeBase + this._staticRoute,
151
+ WORKBENCH_WEB_BASE_URL: staticRoute,
164
152
WORKBENCH_NLS_URL,
165
- - WORKBENCH_NLS_FALLBACK_URL: `${this._staticRoute }/out/nls.messages.js`
166
- + WORKBENCH_NLS_FALLBACK_URL: `${vscodeBase}${this._staticRoute }/out/nls.messages.js`,
167
- + BASE: base ,
168
- + VS_BASE: vscodeBase ,
153
+ - WORKBENCH_NLS_FALLBACK_URL: `${staticRoute }/out/nls.messages.js`
154
+ + WORKBENCH_NLS_FALLBACK_URL: `${staticRoute }/out/nls.messages.js`,
155
+ + BASE: rootBase ,
156
+ + VS_BASE: basePath ,
169
157
};
170
158
171
159
// DEV ---------------------------------------------------------------------------------------
172
- @@ -393 ,7 +398 ,7 @@ export class WebClientServer {
160
+ @@ -419 ,7 +428 ,7 @@ export class WebClientServer {
173
161
'default-src \'self\';',
174
162
'img-src \'self\' https: data: blob:;',
175
163
'media-src \'self\';',
@@ -178,7 +166,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
178
166
'child-src \'self\';',
179
167
`frame-src 'self' https://*.vscode-cdn.net data:;`,
180
168
'worker-src \'self\' data: blob:;',
181
- @@ -466 ,3 +471 ,70 @@ export class WebClientServer {
169
+ @@ -492 ,3 +501 ,70 @@ export class WebClientServer {
182
170
return void res.end(data);
183
171
}
184
172
}
0 commit comments