Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -121,18 +121,20 @@ app = FastAPI()
|
|
121 |
|
122 |
app.add_middleware(
|
123 |
CORSMiddleware,
|
124 |
-
allow_origins=["*"], #
|
125 |
-
allow_methods=["*"], #
|
126 |
-
allow_headers=["*"], #
|
127 |
)
|
128 |
|
129 |
@app.options("/{rest_of_path:path}")
|
130 |
async def preflight_handler(request: Request, rest_of_path: str) -> Response:
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
136 |
|
137 |
@app.on_event("startup")
|
138 |
async def startup():
|
|
|
121 |
|
122 |
app.add_middleware(
|
123 |
CORSMiddleware,
|
124 |
+
allow_origins=["*"], # This allows all domains
|
125 |
+
allow_methods=["*"], # This allows all methods
|
126 |
+
allow_headers=["*"], # This allows all headers
|
127 |
)
|
128 |
|
129 |
@app.options("/{rest_of_path:path}")
|
130 |
async def preflight_handler(request: Request, rest_of_path: str) -> Response:
|
131 |
+
return Response(headers={
|
132 |
+
"Access-Control-Allow-Origin": "*", # Allows all origins
|
133 |
+
"Access-Control-Allow-Methods": "POST, GET, OPTIONS, PUT, DELETE", # Specify methods allowed
|
134 |
+
"Access-Control-Allow-Headers": "*", # Allows all headers
|
135 |
+
})
|
136 |
+
|
137 |
+
|
138 |
|
139 |
@app.on_event("startup")
|
140 |
async def startup():
|