G
G
GaserV2017-04-10 23:28:07
Laravel
GaserV, 2017-04-10 23:28:07

Why doesn't CORS work when added to a route group?

Such a problem. If you do this, then it works:

Route::get('jobs', ['middleware' => 'cors', function()
{
    $jobs = Job::all();
    return Response::json( [ 'jobs' => $jobs ]);

}]);

But if you write like this, it does not work and hits an error:
FatalThrowableError in Router.php line 391:
Type error: Argument 2 passed to Illuminate\Routing\Router::group() must be an instance of Closure, none given, called in

What's wrong?
PS CORS did similar to this - en.vedovelli.com.br/2015/web-development/Laravel-5...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GaserV, 2017-04-10
@GaserV

issue resolved)

Route::group(['middleware' => 'cors'], function(){
    Route::get('jobs', '[email protected]');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question