File tree Expand file tree Collapse file tree
backend/src/acidwatch_api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import os
4+
35import fastapi
46from azure .monitor .opentelemetry import configure_azure_monitor
57from fastapi .middleware .cors import CORSMiddleware
3941 "https://acidwatch.radix.equinor.com" ,
4042]
4143
42- # Allow GitHub Codespaces forwarded URLs (e.g. https://<name>-5173.app.github.dev)
43- codespaces_origin_regex = r"https://[a-z0-9-]+-\d+\.app\.github\.dev"
44+ # Allow CORS for GitHub Codespaces if running in that environment
45+ if codespace_name := os .environ .get ("CODESPACE_NAME" ):
46+ domain = os .environ .get (
47+ "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" , "app.github.dev"
48+ )
49+ origins .append (f"https://{ codespace_name } -5173.{ domain } " )
4450
4551
4652fastapi_app .include_router (router )
4753
4854app = CORSMiddleware (
4955 fastapi_app ,
5056 allow_origins = origins ,
51- allow_origin_regex = codespaces_origin_regex ,
5257 allow_credentials = True ,
5358 allow_methods = ["*" ],
5459 allow_headers = ["*" ],
You can’t perform that action at this time.
0 commit comments