import { logger } from "../logger/index.mjs";

//#region src/utils/cors.ts
const whitelist = [process.env.CLIENT_URL];
const corsOptions = {
	origin: (origin, callback) => {
		if (!origin) return callback(null, true);
		if (whitelist.includes(origin)) {
			logger.info("whitelisted origin", origin);
			return callback(null, true);
		}
		logger.info("non whitelisted origin", origin);
		callback(null, origin);
	},
	allowedHeaders: [
		"authorization",
		"Content-Type",
		"credentials",
		"cache-control",
		"Access-Control-Allow-Origin",
		"private-state-token-redemption",
		"private-state-token-issuance",
		"browsing-topics"
	],
	exposedHeaders: [""],
	preflightContinue: false,
	methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
	credentials: true
};

//#endregion
export { corsOptions };
//# sourceMappingURL=cors.mjs.map