mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Merge pull request #2281 from foxfire52/main
Add support for CORS preflight OPTIONS requests (#2006)
This commit is contained in:
commit
6a1f88e7b7
1 changed files with 8 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ from fastapi.security import APIKeyHeader
|
|||
from starlette.exceptions import HTTPException
|
||||
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from pydantic import BaseModel
|
||||
from typing import Union, Optional
|
||||
|
||||
|
|
@ -24,6 +25,13 @@ from g4f.cookies import read_cookie_files
|
|||
def create_app():
|
||||
app = FastAPI()
|
||||
api = Api(app)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origin_regex=".*",
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
api.register_routes()
|
||||
api.register_authorization()
|
||||
api.register_validation_exception_handler()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue