"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const httpErrorResponse_config_1 = __importDefault(require("../exception/httpErrorResponse.config"));
const logger_config_1 = require("../logger/logger.config");
const allowedOrigins = [
    'http://localhost:3000',
    'http://localhost:5173',
    'http://localhost:5174',
    'https://team-tracker.rinov8.studio',
    'https://tracker-management.netlify.app',
    'https://educator.faysal.design',
    'https://staff.tarbiyah.school',
];
const corsOptions = {
    origin: (origin, callback) => {
        logger_config_1.logger.info("Request's origin: " + origin);
        if (allowedOrigins.indexOf(origin) !== -1 || !origin) {
            logger_config_1.logger.info('Request has been allowed by CORS: ' + origin);
            callback(null, true);
        }
        else {
            callback(new httpErrorResponse_config_1.default('Request has not been allowed by CORS', 403));
        }
    },
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
    credentials: true,
    optionsSuccessStatus: 204,
};
exports.default = corsOptions;
//# sourceMappingURL=cors.config.js.map