File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -55,3 +55,15 @@ export function getFrameDomain() {
55
55
// TODO: now cookies / localstorage are still shared across notebooks. Should we use a unique subdomain per user or notebook?
56
56
return "code.typescriptrepl.com" ;
57
57
}
58
+
59
+ export function getMainDomainFromIframe ( ) {
60
+ if ( ENVIRONMENT === "DEV" ) {
61
+ const port = window . location . host . match ( / ^ 1 2 7 \. 0 \. 0 \. 1 : ( \d + ) $ / ) ! [ 1 ] ;
62
+ return "localhost:" + port ;
63
+ }
64
+
65
+ if ( ENVIRONMENT === "STAGING" ) {
66
+ return window . location . hostname ;
67
+ }
68
+ return "notebooks.typecell.org" ;
69
+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import React from "react";
3
3
import ReactDOM from "react-dom" ;
4
4
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5
5
import * as reo from "react-error-overlay" ;
6
- import { validateFrameDomain } from "./config/security" ;
6
+ import {
7
+ getMainDomainFromIframe ,
8
+ validateFrameDomain ,
9
+ } from "./config/security" ;
7
10
import "./iframe.css" ;
8
11
import Frame from "./runtime/executor/executionHosts/sandboxed/iframesandbox/Frame" ;
9
12
@@ -20,6 +23,7 @@ console.log("Loading iframe", window.location.href);
20
23
21
24
// make sure links open in new window instead of iframe
22
25
const base = document . createElement ( "base" ) ;
26
+ base . setAttribute ( "href" , "//" + getMainDomainFromIframe ( ) ) ;
23
27
base . setAttribute ( "target" , "_blank" ) ;
24
28
document . head . appendChild ( base ) ;
25
29
You can’t perform that action at this time.
0 commit comments