I’ve been building app which has Laravel on backend and VueJS on frontend. In backend i installed
fruitcake/laravel-cors for dealing with CORS (I also use tymon/jwt-auth for api auth). Everything is ok on local server but when i moved my app to production i still got error:
Access to XMLHttpRequest at 'http://api.xxxxx.com/api/' from origin 'http://xxxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.. I tried other packages from github and none of these solved problem.
protected $middleware = [ \Fruitcake\Cors\HandleCors::class, ... ]; protected $middlewareGroups = [ ... 'api' => [ 'cors', ... ], ]; protected $routeMiddleware = [ 'cors' => \Fruitcake\Cors\HandleCors::class, ];
'providers' => [ ... \Fruitcake\Cors\CorsServiceProvider::class, ... ],
return [ 'paths' => ['*'], 'allowed_methods' => ['*'], 'allowed_origins' => ['*'], 'allowed_origins_patterns' => , 'allowed_headers' => ['*'], 'exposed_headers' => false, 'max_age' => false, 'supports_credentials' => false, ];