0.2 在线版本打通
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import Dict
|
||||
from typing import Dict, List, Set
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -8,15 +9,36 @@ from app.routers import api_router, root_router
|
||||
|
||||
app = FastAPI(title="Wolai Backend", version="0.1.0-stage0")
|
||||
|
||||
|
||||
def parse_extra_origins(*values: str) -> List[str]:
|
||||
out: Set[str] = set()
|
||||
for raw in values:
|
||||
if not raw:
|
||||
continue
|
||||
for item in str(raw).split(","):
|
||||
origin = item.strip()
|
||||
if origin:
|
||||
out.add(origin)
|
||||
return sorted(out)
|
||||
|
||||
|
||||
extra_origins = parse_extra_origins(
|
||||
settings.frontend_url,
|
||||
os.getenv("FRONTEND_URLS", ""),
|
||||
os.getenv("CORS_ALLOWED_ORIGINS", ""),
|
||||
)
|
||||
|
||||
allow_origins = [
|
||||
*extra_origins,
|
||||
"http://localhost:3000",
|
||||
"http://localhost:3001",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://127.0.0.1:3001",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
settings.frontend_url,
|
||||
"http://localhost:3000",
|
||||
"http://localhost:3001",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://127.0.0.1:3001",
|
||||
],
|
||||
allow_origins=allow_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
INFO: Started server process [10528]
|
||||
INFO: Waiting for application startup.
|
||||
INFO: Application startup complete.
|
||||
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
|
||||
@@ -0,0 +1,30 @@
|
||||
INFO: 127.0.0.1:56337 - "GET / HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 183.221.18.13:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 183.221.18.13:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 183.221.18.13:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
INFO: 2409:8a62:e45:7c51::16f3:0 - "GET /health HTTP/1.1" 200 OK
|
||||
Reference in New Issue
Block a user