DEBUG: Add auth debugging logs to identify file preview auth issue
This commit is contained in:
parent
4b3f75d4cf
commit
6c1a1fa842
|
|
@ -29,9 +29,22 @@ export const isAuthenticated = async (event: any): Promise<boolean> => {
|
|||
export const requireAuth = async (event: any) => {
|
||||
const authenticated = await isAuthenticated(event);
|
||||
if (!authenticated) {
|
||||
console.log('[requireAuth] Authentication failed for:', event.node.req.url);
|
||||
console.log('[requireAuth] Available headers:', Object.keys(event.node.req.headers));
|
||||
console.log('[requireAuth] Available cookies:', Object.keys(event.node.req.headers.cookie ? parseCookies(event.node.req.headers.cookie) : {}));
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
statusMessage: "Authentication required. Please provide x-tag header or valid session."
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function parseCookies(cookieString: string): Record<string, string> {
|
||||
return cookieString.split(';').reduce((cookies: Record<string, string>, cookie) => {
|
||||
const [name, value] = cookie.trim().split('=');
|
||||
if (name && value) {
|
||||
cookies[name] = value;
|
||||
}
|
||||
return cookies;
|
||||
}, {});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue