You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
334 B
19 lines
334 B
1 year ago
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
from server import app
|
||
|
|
||
|
|
||
|
# 前端页面url
|
||
|
origins = [
|
||
|
"http://localhost:80",
|
||
|
"http://127.0.0.1:80",
|
||
|
]
|
||
|
|
||
|
# 后台api允许跨域
|
||
|
app.add_middleware(
|
||
|
CORSMiddleware,
|
||
|
allow_origins=origins,
|
||
|
allow_credentials=True,
|
||
|
allow_methods=["*"],
|
||
|
allow_headers=["*"],
|
||
|
)
|