perf: Supports dynamic access paths

This commit is contained in:
fit2cloud-chenyw
2026-01-06 12:14:08 +08:00
committed by fit2cloud-chenyw
parent 9112d2f6f0
commit c78fc5d88b
2 changed files with 10 additions and 1 deletions
+3 -1
View File
@@ -28,7 +28,9 @@ class Settings(BaseSettings):
extra="ignore",
)
PROJECT_NAME: str = "SQLBot"
API_V1_STR: str = "/api/v1"
#CONTEXT_PATH: str = "/sqlbot"
CONTEXT_PATH: str = ""
API_V1_STR: str = CONTEXT_PATH + "/api/v1"
SECRET_KEY: str = secrets.token_urlsafe(32)
# 60 minutes * 24 hours * 8 days = 8 days
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
+7
View File
@@ -67,6 +67,13 @@ class WhitelistChecker:
prefix = settings.API_V1_STR
if path.startswith(prefix):
path = path[len(prefix):]
context_prefix = settings.CONTEXT_PATH
if context_prefix and path.startswith(context_prefix):
path = path[len(context_prefix):]
if not path:
path = '/'
if path in self.whitelist:
return True