chenhaoq87 commited on
Commit
657a587
·
verified ·
1 Parent(s): 354fad4

Fix CORS for Custom GPT access

Browse files
Files changed (1) hide show
  1. fastapi_app.py +5 -4
fastapi_app.py CHANGED
@@ -21,13 +21,14 @@ app = FastAPI(
21
  version="1.0.0"
22
  )
23
 
24
- # Add CORS middleware
25
  app.add_middleware(
26
  CORSMiddleware,
27
- allow_origins=["*"],
28
- allow_credentials=True,
29
- allow_methods=["*"],
30
  allow_headers=["*"],
 
31
  )
32
 
33
  # Request/Response models
 
21
  version="1.0.0"
22
  )
23
 
24
+ # Add CORS middleware - Allow requests from OpenAI and all origins
25
  app.add_middleware(
26
  CORSMiddleware,
27
+ allow_origin_regex=r"https://.*\.openai\.com|https://chat\.openai\.com|https://.*",
28
+ allow_credentials=False, # Changed to False for wildcard origins
29
+ allow_methods=["GET", "POST", "OPTIONS"],
30
  allow_headers=["*"],
31
+ expose_headers=["*"],
32
  )
33
 
34
  # Request/Response models