Fix CORS for Custom GPT access
Browse files- 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 |
-
|
| 28 |
-
allow_credentials=
|
| 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
|