Skip to main content
Glama

Carbon Voice

by PhononX
auth-error-logger.middleware.ts985 B
import { NextFunction, Request, Response } from 'express'; import { logger } from '../../../utils'; import { obfuscateAuthHeaders } from '../../../utils/obfuscate-auth-headers'; import { getSessionId } from '../utils'; // Standalone JSON rewrite middleware for logging auth errors export const authErrorLogger = ( req: Request, res: Response, next: NextFunction, ) => { // Override json method to intercept error responses const originalJson = res.json.bind(res); res.json = function (data: unknown) { // Only log if it's an error response if ( res.statusCode >= 400 && data && typeof data === 'object' && 'error' in data ) { logger.error('Authentication error', { sessionId: getSessionId(req), url: req.url, method: req.method, statusCode: res.statusCode, headers: obfuscateAuthHeaders(req.headers), error: data, }); } return originalJson(data); }; next(); };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PhononX/cv-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server