<?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)
    {
        //  http://127.0.0.3:9201/ $response->header
        // $response = $next($request);
        // // $response->headers->set('Access-Control-Expose-Headers', 'Content-Disposition');
        // $response->header('Access-Control-Allow-Origin', 'http://193.2.0.1');
        // $response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
        // $response->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Client-Reference, Application, User-Agent');
        // //return $response->withHeaders($headers);
        // return $response;
        return $next($request)
            ->header('Access-Control-Allow-Origin', 'http://193.2.0.1')
            ->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, DELETE, OPTIONS')
            ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Client-Reference, Application, User-Agent');
    }
}
