fix: allow / and /static/ paths without token so login page can load

This commit is contained in:
2026-07-03 18:30:14 +02:00
parent 16a2429f88
commit f92d2bb642
+5 -2
View File
@@ -16,14 +16,17 @@ DB_PATH = os.environ.get("DB_PATH", "/data/messages.db")
Path(DB_PATH).parent.mkdir(parents=True, exist_ok=True)
TOKEN = os.environ.get("DASHBOARD_TOKEN", "").strip()
PUBLIC_ROUTES = {"/webhook", "/healthz"}
# Public: HTML shell + static assets (login page needs to load) + webhook + health
PUBLIC_ROUTES = {"/", "/webhook", "/healthz"}
PUBLIC_PREFIXES = ("/static/",)
app = Flask(__name__, static_folder="static", static_url_path="/static")
@app.before_request
def _check_token():
if not TOKEN or request.path in PUBLIC_ROUTES:
p = request.path
if not TOKEN or p in PUBLIC_ROUTES or p.startswith(PUBLIC_PREFIXES):
return None
supplied = (
request.headers.get("Authorization", "").removeprefix("Bearer ").strip()