<?php

namespace App\Http\Middleware;

use Closure;

class Cors
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        /*$allowedOrigins = ['https://admin.hospitalia.com.co', 'https://gestioncostos.synergiasa.com'];

        if ($request->server('HTTP_ORIGIN')) {
            $origin = $request->server('HTTP_ORIGIN');

            if (in_array($origin, $allowedOrigins)) {*/
                return $next($request)
                            ->header('Access-Control-Allow-Origin', '*')
                            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
                            ->header('Access-Control-Allow-Headers', 'Content-Type, X-Auth-Token, Accept, Authorization, Origin');
            /*}
        }*/

        return $next($request);
    }
}
