File tree 3 files changed +16
-10
lines changed
3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -127,11 +127,13 @@ export default function Playground() {
127
127
128
128
// We're using a random subdomain for origin isolation.
129
129
const url = new URL (
130
- `${ window . location . protocol } //${
131
- PLAYGROUND_BASE_HOST . startsWith ( "localhost" )
132
- ? ""
133
- : `${ subdomain . current } .`
134
- } ${ PLAYGROUND_BASE_HOST } `
130
+ window . location . hostname . endsWith ( "localhost" )
131
+ ? window . location . origin
132
+ : `${ window . location . protocol } //${
133
+ PLAYGROUND_BASE_HOST . startsWith ( "localhost" )
134
+ ? ""
135
+ : `${ subdomain . current } .`
136
+ } ${ PLAYGROUND_BASE_HOST } `
135
137
) ;
136
138
setVConsole ( [ ] ) ;
137
139
url . searchParams . set ( "state" , state ) ;
Original file line number Diff line number Diff line change @@ -35,15 +35,17 @@ export async function initPlayIframe(
35
35
JSON . stringify ( editorContent )
36
36
) ;
37
37
const path = iframe . getAttribute ( "data-live-path" ) ;
38
- const host = PLAYGROUND_BASE_HOST . startsWith ( "localhost" )
39
- ? PLAYGROUND_BASE_HOST
40
- : `${ hash } .${ PLAYGROUND_BASE_HOST } ` ;
41
38
const url = new URL (
42
39
`${ path || "" } ${ path ?. endsWith ( "/" ) ? "" : "/" } runner.html` ,
43
40
window . location . origin
44
41
) ;
45
- url . port = "" ;
46
- url . host = host ;
42
+ if ( ! window . location . hostname . endsWith ( "localhost" ) ) {
43
+ const host = PLAYGROUND_BASE_HOST . startsWith ( "localhost" )
44
+ ? PLAYGROUND_BASE_HOST
45
+ : `${ hash } .${ PLAYGROUND_BASE_HOST } ` ;
46
+ url . port = "" ;
47
+ url . host = host ;
48
+ }
47
49
url . search = "" ;
48
50
url . searchParams . set ( "state" , state ) ;
49
51
iframe . src = url . href ;
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ function config(app) {
20
20
app . use ( `**/*.(gif|jpeg|jpg|mp3|mp4|ogg|png|svg|webm|webp|woff2)` , proxy ) ;
21
21
// All those root-level images like /favicon-48x48.png
22
22
app . use ( "/*.(png|webp|gif|jpe?g|svg)" , proxy ) ;
23
+ // Proxy play runner
24
+ app . use ( "/**/runner.html" , proxy ) ;
23
25
}
24
26
25
27
export default config ;
You can’t perform that action at this time.
0 commit comments