Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -119,6 +119,21 @@ WorkExperience = sqlalchemy.Table(
|
|
119 |
|
120 |
app = FastAPI()
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
@app.on_event("startup")
|
123 |
async def startup():
|
124 |
await database.connect()
|
|
|
119 |
|
120 |
app = FastAPI()
|
121 |
|
122 |
+
app.add_middleware(
|
123 |
+
CORSMiddleware,
|
124 |
+
allow_origins=["*"], # Allow all origins
|
125 |
+
allow_methods=["*"], # Allow all methods
|
126 |
+
allow_headers=["*"], # Allow all headers
|
127 |
+
)
|
128 |
+
|
129 |
+
@app.options("/{rest_of_path:path}")
|
130 |
+
async def preflight_handler(request: Request, rest_of_path: str) -> Response:
|
131 |
+
response = JSONResponse(content={})
|
132 |
+
response.headers["Access-Control-Allow-Origin"] = "*"
|
133 |
+
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
|
134 |
+
response.headers["Access-Control-Allow-Headers"] = "Authorization, Content-Type"
|
135 |
+
return response
|
136 |
+
|
137 |
@app.on_event("startup")
|
138 |
async def startup():
|
139 |
await database.connect()
|