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

//#region src/utils/cors.ts
const whitelist = [process.env.APP_URL];
const corsOptions = {
	origin: (origin, callback) => {
		if (!origin) {
			callback(null, true);
			return;
		}
		if (whitelist.includes(origin)) {
			logger.info("whitelisted origin", origin);
			callback(null, true);
			return;
		}
		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: [""],
	methods: [
		"GET",
		"HEAD",
		"PUT",
		"PATCH",
		"POST",
		"DELETE"
	],
	credentials: true
};

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