debug: add logging to htmx auth header
This commit is contained in:
parent
7bb230b59c
commit
c6fc5306c6
1 changed files with 17 additions and 0 deletions
|
|
@ -6,13 +6,30 @@
|
|||
// CRITICAL: Register auth header listener IMMEDIATELY on document
|
||||
// This MUST run before any HTMX requests are made
|
||||
// =========================================================================
|
||||
console.log(
|
||||
"[HTMX-AUTH] Registering htmx:configRequest listener on document",
|
||||
);
|
||||
|
||||
document.addEventListener("htmx:configRequest", (event) => {
|
||||
// Add Authorization header with access token
|
||||
const accessToken =
|
||||
localStorage.getItem("gb-access-token") ||
|
||||
sessionStorage.getItem("gb-access-token");
|
||||
|
||||
console.log(
|
||||
"[HTMX-AUTH] configRequest for:",
|
||||
event.detail.path,
|
||||
"token:",
|
||||
accessToken ? accessToken.substring(0, 20) + "..." : "NONE",
|
||||
);
|
||||
|
||||
if (accessToken) {
|
||||
event.detail.headers["Authorization"] = `Bearer ${accessToken}`;
|
||||
console.log("[HTMX-AUTH] Authorization header SET");
|
||||
} else {
|
||||
console.warn(
|
||||
"[HTMX-AUTH] NO TOKEN FOUND - request will be unauthenticated",
|
||||
);
|
||||
}
|
||||
|
||||
// Add CSRF token if available
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue