mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 19:57:30 -05:00 
			
		
		
		
	* Refactor for user * payment notifications * Fixes for contact request * Fix validation for contacts * Fixes for base repo * Fixes for Invoice Repo * hide password field on clientcontact
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Middleware;
 | 
						|
 | 
						|
use Closure;
 | 
						|
use Illuminate\Support\Facades\Response;
 | 
						|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
 | 
						|
 | 
						|
class Cors
 | 
						|
{
 | 
						|
    public function handle($request, Closure $next)
 | 
						|
    {
 | 
						|
        if ($request->getMethod() == "OPTIONS") {
 | 
						|
            header("Access-Control-Allow-Origin: *");
 | 
						|
 | 
						|
            // ALLOW OPTIONS METHOD
 | 
						|
            $headers = [
 | 
						|
                'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
 | 
						|
                'Access-Control-Allow-Headers'=> 'X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'
 | 
						|
            ];
 | 
						|
 | 
						|
            return Response::make('OK', 200, $headers);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        /* Work around for file downloads where the response cannot contain have headers set */
 | 
						|
        // if($request instanceOf BinaryFileResponse)
 | 
						|
        //   return $next($request);
 | 
						|
        // else
 | 
						|
        // return $next($request)
 | 
						|
        //   ->header('Access-Control-Allow-Origin', '*')
 | 
						|
        //   ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
 | 
						|
        //   ->header('Access-Control-Allow-Headers', 'X-API-SECRET,X-API-TOKEN,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range');
 | 
						|
 | 
						|
        $response = $next($request);
 | 
						|
 | 
						|
        $response->headers->set('Access-Control-Allow-Origin', '*');
 | 
						|
        $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
 | 
						|
        $response->headers->set('Access-Control-Allow-Headers', 'X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range');
 | 
						|
        $response->headers->set('X-APP-VERSION', config('ninja.app_version'));
 | 
						|
        $response->headers->set('X-API-VERSION', config('ninja.api_version'));
 | 
						|
        
 | 
						|
        return $response;
 | 
						|
    }
 | 
						|
}
 |