vk98's picture
Initial backend deployment - Hono proxy + ColPali embedding API
5dfbe50
raw
history blame contribute delete
707 Bytes
import { cors as honoCors } from 'hono/cors';
import { config } from '../config';
export const corsMiddleware = honoCors({
origin: (origin) => {
// Allow configured origin and localhost in development
const allowedOrigins = [config.corsOrigin];
if (config.nodeEnv === 'development') {
allowedOrigins.push('http://localhost:3000', 'http://localhost:3001', 'http://localhost:3025');
}
return allowedOrigins.includes(origin) ? origin : allowedOrigins[0];
},
allowHeaders: ['Content-Type', 'Authorization', 'X-Request-ID'],
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
exposeHeaders: ['X-Total-Count', 'X-Request-ID'],
maxAge: 86400,
credentials: true,
});