Fix CORS and linting in app.ts for stable deploy

This commit is contained in:
2026-08-27 14:44:32 +00:00
parent f8cda3d219
commit 32632c1c35
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -58,7 +58,7 @@ app.use(cors({
} }
}, },
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'x-organization-id'] allowedHeaders: ['Content-Type', 'Authorization', 'x-organization-id', 'x-organization-name']
})); }));
app.use(express.json({ limit: '5mb' })); app.use(express.json({ limit: '5mb' }));
@@ -111,7 +111,7 @@ app.use((req, res, next) => {
}); });
// Error handler // Error handler
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => { app.use((err: Error, req: express.Request, res: express.Response, _next: express.NextFunction) => {
console.error('Express Error:', err); console.error('Express Error:', err);
if (err.message === 'Not allowed by CORS') { if (err.message === 'Not allowed by CORS') {
return res.status(403).json({ error: 'CORS error' }); return res.status(403).json({ error: 'CORS error' });
+3
View File
@@ -13,6 +13,7 @@ export async function authenticateRequest(req: Request): Promise<IAppUser | null
const authHeader = req.headers.authorization; const authHeader = req.headers.authorization;
if (!authHeader?.startsWith('Bearer ')) { if (!authHeader?.startsWith('Bearer ')) {
console.log('[Auth] Missing or invalid authorization header:', authHeader);
return null; return null;
} }
@@ -28,6 +29,8 @@ export async function authenticateRequest(req: Request): Promise<IAppUser | null
}; };
} }
console.log('[Auth] Verifying real token starting with:', token.substring(0, 15) + '...');
try { try {
const { payload } = await jwtVerify(token, jwks, { const { payload } = await jwtVerify(token, jwks, {
issuer: `${LOGTO_URL}/oidc`, issuer: `${LOGTO_URL}/oidc`,