Cors Laravel, release only for a specific domain

1

I'm using the LaravelCors library and would like to block all requesters except a specific Domain, how do I do this?

    
asked by anonymous 05.02.2018 / 00:10

1 answer

1

If the entire installation has been followed barryvdh / laravel-cors goes in the config folder and open the file cors.php and array of settings, add the address in the allowedOrigins key as it is now in the example below the address http://www.teste.com , it can also contain other addresses because it accepts more settings.

return [
     /*
     |--------------------------------------------------------------------------
     | Laravel CORS
     |--------------------------------------------------------------------------
     |
     | allowedOrigins, allowedHeaders and allowedMethods can be set to array('*')
     | to accept any value.
     |
     */
    'supportsCredentials' => false,
    'allowedOrigins' => ['http://www.teste.com'],
    'allowedHeaders' => ['Content-Type', 'X-Requested-With'],
    'allowedMethods' => ['*'], // ex: ['GET', 'POST', 'PUT',  'DELETE']
    'exposedHeaders' => [],
    'maxAge' => 0,
]
    
05.02.2018 / 01:27