Skip to content

Commit c78fc5d

Browse files
perf: Supports dynamic access paths
1 parent 9112d2f commit c78fc5d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

backend/common/core/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class Settings(BaseSettings):
2828
extra="ignore",
2929
)
3030
PROJECT_NAME: str = "SQLBot"
31-
API_V1_STR: str = "/api/v1"
31+
#CONTEXT_PATH: str = "/sqlbot"
32+
CONTEXT_PATH: str = ""
33+
API_V1_STR: str = CONTEXT_PATH + "/api/v1"
3234
SECRET_KEY: str = secrets.token_urlsafe(32)
3335
# 60 minutes * 24 hours * 8 days = 8 days
3436
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8

backend/common/utils/whitelist.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ def is_whitelisted(self, path: str) -> bool:
6767
prefix = settings.API_V1_STR
6868
if path.startswith(prefix):
6969
path = path[len(prefix):]
70+
71+
context_prefix = settings.CONTEXT_PATH
72+
if context_prefix and path.startswith(context_prefix):
73+
path = path[len(context_prefix):]
74+
75+
if not path:
76+
path = '/'
7077
if path in self.whitelist:
7178
return True
7279

0 commit comments

Comments
 (0)