mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-09-25 06:26:57 +00:00
Add basic CORS (#1198)
This commit is contained in:
@@ -3,11 +3,50 @@ from pydantic import BaseModel, Field
|
||||
from private_gpt.settings.settings_loader import load_active_profiles
|
||||
|
||||
|
||||
class CorsSettings(BaseModel):
|
||||
"""CORS configuration.
|
||||
|
||||
For more details on the CORS configuration, see:
|
||||
# * https://fastapi.tiangolo.com/tutorial/cors/
|
||||
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
"""
|
||||
|
||||
enabled: bool = Field(
|
||||
description="Flag indicating if CORS headers are set or not."
|
||||
"If set to True, the CORS headers will be set to allow all origins, methods and headers."
|
||||
)
|
||||
allow_credentials: bool = Field(
|
||||
description="Indicate that cookies should be supported for cross-origin requests",
|
||||
default=False,
|
||||
)
|
||||
allow_origins: list[str] = Field(
|
||||
description="A list of origins that should be permitted to make cross-origin requests.",
|
||||
default=[],
|
||||
)
|
||||
allow_origin_regex: list[str] = Field(
|
||||
description="A regex string to match against origins that should be permitted to make cross-origin requests.",
|
||||
default=None,
|
||||
)
|
||||
allow_methods: list[str] = Field(
|
||||
description="A list of HTTP methods that should be allowed for cross-origin requests.",
|
||||
default=[
|
||||
"GET",
|
||||
],
|
||||
)
|
||||
allow_headers: list[str] = Field(
|
||||
description="A list of HTTP request headers that should be supported for cross-origin requests.",
|
||||
default=[],
|
||||
)
|
||||
|
||||
|
||||
class ServerSettings(BaseModel):
|
||||
env_name: str = Field(
|
||||
description="Name of the environment (prod, staging, local...)"
|
||||
)
|
||||
port: int = Field("Port of PrivateGPT FastAPI server, defaults to 8001")
|
||||
port: int = Field(description="Port of PrivateGPT FastAPI server, defaults to 8001")
|
||||
cors: CorsSettings = Field(
|
||||
description="CORS configuration", default=CorsSettings(enabled=False)
|
||||
)
|
||||
|
||||
|
||||
class DataSettings(BaseModel):
|
||||
|
Reference in New Issue
Block a user