TikTok redirect URI and callback use trailing slash

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-14 09:36:50 -05:00
parent e1e20d1af8
commit eceefbe7cb
5 changed files with 8 additions and 4 deletions

View File

@ -11,6 +11,7 @@ from .config import settings
# OAuth redirect + SSE + static covers — never block # OAuth redirect + SSE + static covers — never block
_PUBLIC_PATHS = { _PUBLIC_PATHS = {
"/api/shorts/oauth/callback", "/api/shorts/oauth/callback",
"/api/tiktok/oauth/callback/",
"/api/tiktok/oauth/callback", "/api/tiktok/oauth/callback",
"/api/events/stream", "/api/events/stream",
} }

View File

@ -426,7 +426,7 @@ def _seed_defaults(conn: sqlite3.Connection) -> None:
"tiktok_oauth_check_interval_sec": 3600, "tiktok_oauth_check_interval_sec": 3600,
"tiktok_oauth_client_key": "", "tiktok_oauth_client_key": "",
"tiktok_oauth_client_secret": "", "tiktok_oauth_client_secret": "",
"tiktok_oauth_redirect_uri": "https://dylive.nomadro.com/api/tiktok/oauth/callback", "tiktok_oauth_redirect_uri": "https://dylive.nomadro.com/api/tiktok/oauth/callback/",
} }
for key, value in defaults.items(): for key, value in defaults.items():
row = conn.execute("SELECT 1 FROM kv_settings WHERE key = ?", (key,)).fetchone() row = conn.execute("SELECT 1 FROM kv_settings WHERE key = ?", (key,)).fetchone()

View File

@ -894,6 +894,7 @@ async def tiktok_url_prefix_verify_file() -> FileResponse:
@app.get("/api/tiktok/oauth/callback") @app.get("/api/tiktok/oauth/callback")
@app.get("/api/tiktok/oauth/callback/")
async def tiktok_oauth_callback( async def tiktok_oauth_callback(
request: Request, request: Request,
code: str = "", code: str = "",

View File

@ -28,6 +28,7 @@ _PUBLIC_API_PREFIXES = (
_PUBLIC_API_EXACT = { _PUBLIC_API_EXACT = {
"/api/health", "/api/health",
"/api/shorts/oauth/callback", "/api/shorts/oauth/callback",
"/api/tiktok/oauth/callback/",
"/api/tiktok/oauth/callback", "/api/tiktok/oauth/callback",
"/api/events/stream", "/api/events/stream",
} }

View File

@ -37,11 +37,12 @@ def resolve_redirect_uri(request_base: str = "") -> str:
cfg = _cfg() cfg = _cfg()
custom = str(cfg.get("tiktok_oauth_redirect_uri") or "").strip() custom = str(cfg.get("tiktok_oauth_redirect_uri") or "").strip()
if custom: if custom:
return custom.rstrip("/") uri = custom.rstrip("/") + "/"
return uri
base = (request_base or "").rstrip("/") base = (request_base or "").rstrip("/")
if base: if base:
return f"{base}/api/tiktok/oauth/callback" return f"{base}/api/tiktok/oauth/callback/"
return "https://dylive.nomadro.com/api/tiktok/oauth/callback" return "https://dylive.nomadro.com/api/tiktok/oauth/callback/"
def setup_checklist(cfg: dict[str, Any] | None = None) -> dict[str, Any]: def setup_checklist(cfg: dict[str, Any] | None = None) -> dict[str, Any]: