test ci/cd
This commit is contained in:
commit
1e8243ab9a
265 changed files with 216965 additions and 0 deletions
30
SRV/config/cors.py
Normal file
30
SRV/config/cors.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from fastapi import FastAPI
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
|
||||
class CORSMiddlewareConfig:
|
||||
"""
|
||||
Класс для настройки CORS политики в FastAPI
|
||||
"""
|
||||
|
||||
def __init__(self, app: FastAPI) -> None:
|
||||
"""Инициализируем приложение FastAPI и список допустимых CORS-оригинов"""
|
||||
self.app = app
|
||||
self.origins = [
|
||||
"http://localhost.tiangolo.com",
|
||||
"https://localhost.tiangolo.com",
|
||||
"http://localhost",
|
||||
"http://localhost:8080",
|
||||
"http://localhost:5174",
|
||||
"http://localhost:5173",
|
||||
]
|
||||
|
||||
def add_cors_middleware(self) -> None:
|
||||
"""Добавляем CORS в приложение FastAPI"""
|
||||
self.app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=self.origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue