<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

class ApiCors extends BaseConfig
{
    /**
     * Allowed frontend origins for API CORS.
     *
     * @var string[]
     */
    public array $allowedOrigins = [
        'http://localhost:3000',
        'http://localhost:3002',
        'https://busvalley.com',
        'https://www.busvalley.com',
        'https://busvalley.net',
        'https://www.busvalley.net',
        'https://good.busvalley.com',
        'https://www.good.busvalley.com',
    ];

    /**
     * Allowed CORS methods.
     *
     * @var string[]
     */
    public array $allowedMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'];

    /**
     * Allowed CORS headers.
     *
     * @var string[]
     */
    public array $allowedHeaders = ['Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'Authorization'];

    /**
     * Exposed CORS headers.
     *
     * @var string[]
     */
    public array $exposedHeaders = ['Content-Length', 'Content-Type'];

    /**
     * Allow browser credentials for whitelisted origins.
     */
    public bool $supportsCredentials = true;

    /**
     * Preflight cache duration.
     */
    public int $maxAge = 600;
}
