Add Compose, Gitea deploy, and Postgres dual-backend on develop.
Use host ports 3006/8005 and 3096/8096 so Kansho does not collide with Bookstack on 3005 or the sister products. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
32acdc220b
commit
07479f6a9f
37 files changed
+1613
-102
No files matched your search
+24
-1
@@ -2,6 +2,8 @@ from env_loader import load_env_file
|
||||
|
||||
load_env_file()
|
||||
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
@@ -10,11 +12,32 @@ import data_layer_dialogue # noqa: F401
|
||||
from routers import admin, auth, dialogue, generation_instructions, journal, placeholders, prompts, subscription, users
|
||||
from version import APP_VERSION
|
||||
|
||||
|
||||
def allowed_origins() -> list[str]:
|
||||
origins = [
|
||||
"http://localhost:5188",
|
||||
"http://127.0.0.1:5188",
|
||||
"https://kansho.jinkendo.de",
|
||||
"https://dev.kansho.jinkendo.de",
|
||||
]
|
||||
extra = (os.environ.get("ALLOWED_ORIGINS") or os.environ.get("KANSHO_ALLOWED_ORIGINS") or "").strip()
|
||||
if extra:
|
||||
origins.extend(item.strip() for item in extra.split(",") if item.strip())
|
||||
app_url = (os.environ.get("APP_URL") or "").strip().rstrip("/")
|
||||
if app_url:
|
||||
origins.append(app_url)
|
||||
seen: list[str] = []
|
||||
for item in origins:
|
||||
if item not in seen:
|
||||
seen.append(item)
|
||||
return seen
|
||||
|
||||
|
||||
app = FastAPI(title="Kanshō", version=APP_VERSION)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5188", "http://127.0.0.1:5188"],
|
||||
allow_origins=allowed_origins(),
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
Reference in new issue
Block a user