@kdump/code-cli-any-llm
Version:
> A unified gateway for the Gemini, opencode, crush, and Qwen Code AI CLIs
50 lines • 1.61 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.corsConfig = void 0;
exports.corsConfig = {
origin: (origin, callback) => {
const allowedOrigins = process.env.CAL_ALLOWED_ORIGINS?.split(',') || [
'http://localhost:3000',
'http://localhost:4200',
'http://localhost:8080',
'app://localhost',
];
if (!origin) {
return callback(null, true);
}
if (process.env.NODE_ENV === 'development') {
return callback(null, true);
}
if (allowedOrigins.includes(origin)) {
return callback(null, true);
}
const isSubdomainAllowed = allowedOrigins.some((allowedOrigin) => {
if (allowedOrigin.startsWith('*.')) {
const domain = allowedOrigin.slice(2);
return origin.endsWith(domain);
}
return false;
});
if (isSubdomainAllowed) {
return callback(null, true);
}
callback(new Error(`Origin ${origin} not allowed by CORS`));
},
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
allowedHeaders: [
'Content-Type',
'Authorization',
'X-Requested-With',
'Accept',
'Origin',
'Access-Control-Allow-Origin',
'Access-Control-Allow-Headers',
'Access-Control-Allow-Methods',
'x-api-key',
'x-gemini-api-key',
],
credentials: true,
maxAge: 86400,
optionsSuccessStatus: 200,
};
//# sourceMappingURL=cors.config.js.map
;