Fix CORS and linting in app.ts for stable deploy
This commit is contained in:
+2
-2
@@ -58,7 +58,7 @@ app.use(cors({
|
||||
}
|
||||
},
|
||||
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' }));
|
||||
@@ -111,7 +111,7 @@ app.use((req, res, next) => {
|
||||
});
|
||||
|
||||
// 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);
|
||||
if (err.message === 'Not allowed by CORS') {
|
||||
return res.status(403).json({ error: 'CORS error' });
|
||||
|
||||
@@ -13,6 +13,7 @@ export async function authenticateRequest(req: Request): Promise<IAppUser | null
|
||||
const authHeader = req.headers.authorization;
|
||||
|
||||
if (!authHeader?.startsWith('Bearer ')) {
|
||||
console.log('[Auth] Missing or invalid authorization header:', authHeader);
|
||||
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 {
|
||||
const { payload } = await jwtVerify(token, jwks, {
|
||||
issuer: `${LOGTO_URL}/oidc`,
|
||||
|
||||
Reference in New Issue
Block a user