Do0rMaMu commited on
Commit
a71e3c6
·
verified ·
1 Parent(s): a889f09

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -8
main.py CHANGED
@@ -121,18 +121,20 @@ 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():
 
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():