Skip to content

Commit 7389d9e

Browse files
committed
Use current URL for webview
1 parent 1d61cbe commit 7389d9e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ Our changes include:
111111
- Add a `code-server` schema.
112112
- Allow multiple extension directories (both user and built-in).
113113
- Rewrite assets requested by the browser to use the base URL.
114-
- Modify the loader to use the base URL.
115-
- Modify the web socket to use the base URL and TLS if necessary.
114+
- Modify the loader, websocket, webview, and service worker to use the URL of
115+
the page as a base (and TLS if necessary for the websocket).
116116
- Send client-side telemetry through the server.
117117
- Add a file prefix to ignore for temporary files created during upload.
118118
- Insert our upload service for use in editor windows and explorer.

scripts/vscode.patch

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ index 5b06636edb..60b508079a 100644
174174
<!-- Require our AMD loader -->
175175
<script src="./out/vs/loader.js"></script>
176176
diff --git a/src/vs/code/browser/workbench/workbench.js b/src/vs/code/browser/workbench/workbench.js
177-
index 65fae7c82d..c9744007c9 100644
177+
index 65fae7c82d..9a9b8bbe3b 100644
178178
--- a/src/vs/code/browser/workbench/workbench.js
179179
+++ b/src/vs/code/browser/workbench/workbench.js
180-
@@ -7,15 +7,20 @@
180+
@@ -7,21 +7,26 @@
181181

182182
(function () {
183183

@@ -205,6 +205,14 @@ index 65fae7c82d..c9744007c9 100644
205205
}
206206
});
207207

208+
require(['vs/workbench/workbench.web.api'], function (api) {
209+
const options = JSON.parse(document.getElementById('vscode-workbench-web-configuration').getAttribute('data-settings'));
210+
-
211+
+ options.webviewEndpoint = `${base}/webview/`;
212+
api.create(document.body, options);
213+
});
214+
})();
215+
\ No newline at end of file
208216
diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts
209217
index a6c9eb9d11..3f8995b727 100644
210218
--- a/src/vs/platform/environment/common/environment.ts

src/server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ export class MainServer extends Server {
469469
const workspacePath = parsedUrl.query.workspace as string | undefined;
470470
const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || this.options.folderUri || cwd: undefined;
471471
const remoteAuthority = request.headers.host as string;
472-
const webviewEndpoint = this.withBase(request, "/webview/");
473472
const transformer = getUriTransformer(remoteAuthority);
474473
const options: Options = {
475474
WORKBENCH_WEB_CONGIGURATION: {
@@ -480,7 +479,6 @@ export class MainServer extends Server {
480479
? transformer.transformOutgoing(URI.file(sanitizeFilePath(folderPath, cwd)))
481480
: undefined,
482481
remoteAuthority,
483-
webviewEndpoint,
484482
},
485483
REMOTE_USER_DATA_URI: transformer.transformOutgoing(
486484
(this.services.get(IEnvironmentService) as EnvironmentService).webUserDataHome,
@@ -497,7 +495,7 @@ export class MainServer extends Server {
497495
for (const key in options) {
498496
content = content.replace(`"{{${key}}}"`, `'${JSON.stringify(options[key as keyof Options])}'`);
499497
}
500-
content = content.replace('{{WEBVIEW_ENDPOINT}}', webviewEndpoint);
498+
content = content.replace("{{WEBVIEW_ENDPOINT}}", "");
501499

502500
return { content, filePath };
503501
}

0 commit comments

Comments
 (0)