Access-Control-Allow-Origin header support

This commit is contained in:
2024-02-19 18:14:55 +08:00
parent fccde86721
commit 3b53f31d9e

View File

@@ -37,6 +37,7 @@ c.DockerSpawner.remove = True
# For debugging arguments passed to spawned containers # For debugging arguments passed to spawned containers
c.DockerSpawner.debug = True c.DockerSpawner.debug = True
# c.Application.log_level = 'DEBUG'
# User containers will access hub by container name on the Docker network # User containers will access hub by container name on the Docker network
c.JupyterHub.hub_ip = 'jupyterhub' c.JupyterHub.hub_ip = 'jupyterhub'
@@ -57,6 +58,22 @@ admin = os.environ.get("JUPYTERHUB_ADMIN")
if admin: if admin:
c.Authenticator.admin_users = [admin] c.Authenticator.admin_users = [admin]
# c.DockerSpawner.extra_create_kwargs.update({
# "environment": {"JUPYTER_ENABLE_LAB": "yes"}
# })
c.DockerSpawner.extra_create_kwargs.update({
"environment": {"NOTEBOOK_ARGS": "--NotebookApp.allow_origin='*'"}
})
# 要支持正则匹配的域名请求,可以通过设置 allow_origin_pat 参数来实现。这个参数允许你使用正则表达式来匹配允许跨域请求的域名。例如,如果你想允许所有以 .example.com 结尾的域名进行跨域请求,可以在 jupyterhub_config.py 文件中添加如下配置:
# c.Spawner.environment = {
# 'JUPYTERHUB_CORS': '{"allow_origin_pat": "https?://.*\\.example\\.com"}'
# }
# GPU 和网络配置 # GPU 和网络配置
c.DockerSpawner.extra_host_config = { c.DockerSpawner.extra_host_config = {
'runtime': 'nvidia' 'runtime': 'nvidia'
@@ -65,3 +82,4 @@ c.DockerSpawner.environment = {
'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility', 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',
'NVIDIA_VISIBLE_DEVICES': 'all' 'NVIDIA_VISIBLE_DEVICES': 'all'
} }