@@ -52,6 +52,32 @@ function escapeJSON(value: unknown): string {
5252function renderWorkbench ( protocol : string , host : string , folderConfig : Record < string , unknown > | null ) : string {
5353 const baseUrl = `${ protocol } ://${ host } /vscode-static` ;
5454
55+ // Use UUID subdomains on localhost (Chrome resolves *.localhost automatically).
56+ // On production, use same-origin since wildcard DNS is not configured.
57+ const isLocalhost = host . startsWith ( "localhost" ) || host . startsWith ( "127.0.0.1" ) ;
58+ const webEndpoint = isLocalhost
59+ ? `${ protocol } ://{{uuid}}.${ host } /vscode-static`
60+ : `${ protocol } ://${ host } /vscode-static` ;
61+
62+ const productConfiguration : Record < string , unknown > = {
63+ enableTelemetry : false ,
64+ nameShort : "ModelScript" ,
65+ nameLong : "ModelScript IDE" ,
66+ webEndpointUrlTemplate : webEndpoint ,
67+ extensionAllowedProposedApi : [ "modelscript.modelscript" ] ,
68+ // Use Open VSX registry to avoid CORS errors with Microsoft's CDN
69+ extensionGallery : {
70+ serviceUrl : "https://open-vsx.org/vscode/gallery" ,
71+ itemUrl : "https://open-vsx.org/vscode/item" ,
72+ resourceUrlTemplate : "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}" ,
73+ controlUrl : "" ,
74+ } ,
75+ } ;
76+
77+ if ( isLocalhost ) {
78+ productConfiguration . webviewContentExternalBaseUrlTemplate = `${ protocol } ://{{uuid}}.${ host } /vscode-static/out/vs/workbench/contrib/webview/browser/pre/` ;
79+ }
80+
5581 const config : Record < string , unknown > = {
5682 additionalBuiltinExtensions : [ ] ,
5783 developmentOptions : {
@@ -60,21 +86,7 @@ function renderWorkbench(protocol: string, host: string, folderConfig: Record<st
6086 { scheme : protocol , authority : host , path : "/static/extensions/github-fs" } ,
6187 ] ,
6288 } ,
63- productConfiguration : {
64- enableTelemetry : false ,
65- nameShort : "ModelScript" ,
66- nameLong : "ModelScript IDE" ,
67- webEndpointUrlTemplate : `${ protocol } ://{{uuid}}.${ host } /vscode-static` ,
68- webviewContentExternalBaseUrlTemplate : `${ protocol } ://{{uuid}}.${ host } /vscode-static/out/vs/workbench/contrib/webview/browser/pre/` ,
69- extensionAllowedProposedApi : [ "modelscript.modelscript" ] ,
70- // Use Open VSX registry to avoid CORS errors with Microsoft's CDN
71- extensionGallery : {
72- serviceUrl : "https://open-vsx.org/vscode/gallery" ,
73- itemUrl : "https://open-vsx.org/vscode/item" ,
74- resourceUrlTemplate : "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}" ,
75- controlUrl : "" ,
76- } ,
77- } ,
89+ productConfiguration,
7890 } ;
7991
8092 if ( folderConfig ) {
0 commit comments