Files
intelligent-daily-report-sy…/plugin/cors/cors.py
2026-02-25 15:22:23 +08:00

24 lines
624 B
Python

from fastapi import FastAPI
from plugin.base import Plugin
class CorsPlugin(Plugin):
def __init__(self, app: FastAPI):
self.name = "CorsPlugin"
self.description = "Enable Cross-Origin Resource Sharing (CORS)"
self.version = "1.0.0"
self.app = app
def install(self):
from fastapi.middleware.cors import CORSMiddleware
# 添加CORS中间件解决跨域问题
self.app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)