Skip to content

Commit 0f4622a

Browse files
committed
Add proxy config support
1 parent 36188b4 commit 0f4622a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/ui/blackboard/jupyterhublet.jsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3131
import { JupyterEdit } from '@fails-components/jupyter-react-edit'
3232
import { OverlayPanel } from 'primereact/overlaypanel'
3333

34+
const jupyterProxyDomains =
35+
import.meta.env.REACT_APP_JUPYTER_PROXY_DOMAINS.split(' ').map(
36+
(el) => 'https://' + el
37+
)
38+
3439
export class AppletButton extends Component {
3540
constructor(args) {
3641
super(args)
@@ -647,6 +652,30 @@ export class JupyterHublet extends Component {
647652
// we just got mounted, we should load the file
648653
this.pendingStateUpdates = [] // clear state updates
649654
this.kernelReady = false
655+
656+
fetch(new URL('/config/proxy.json', window.location.origin), {
657+
method: 'GET',
658+
headers: {
659+
'Content-Type': 'application/json'
660+
}
661+
})
662+
.then(async (res) => {
663+
if (!res.ok) {
664+
throw new Error('HTTP error! status:' + res.status)
665+
}
666+
const config = await res.json()
667+
console.log('We got a proxy config', config)
668+
if (config?.allowedSites) {
669+
this.setState({ allowedSites: config.allowedSites })
670+
}
671+
})
672+
.catch((error) => {
673+
console.log(
674+
'Get config/proxy.json problem/not found, this must not be an error',
675+
error
676+
)
677+
})
678+
650679
this.jState.flushCompress()
651680
this.tryLoadJupyterFile()
652681
if (this.props.setStateReceiver) {
@@ -1231,6 +1260,11 @@ export class JupyterHublet extends Component {
12311260
!!this.props
12321261
.makeAppletMaster /* only install, if it can become master */
12331262
}
1263+
GDPRProxy={{
1264+
proxySites: jupyterProxyDomains,
1265+
allowedSites: this.state.allowedSites || [],
1266+
proxyURL: globalThis.location.origin + '/jupyter/proxy/'
1267+
}}
12341268
ref={this.jupyteredit}
12351269
document={this.state.jupyterDocument}
12361270
filename={this.props.ipynb?.filename}

0 commit comments

Comments
 (0)