mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-28 15:47:59 +01:00
Enabled CORS locally
This commit is contained in:
parent
b163d70e9c
commit
f7bc4f0565
3 changed files with 20 additions and 1 deletions
|
@ -58,5 +58,6 @@ class Kernel extends HttpKernel
|
|||
'json-exceptions' => \Poniverse\Ponyfm\Http\Middleware\JsonExceptions::class,
|
||||
'guest' => \Poniverse\Ponyfm\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'cors' => \Poniverse\Ponyfm\Http\Middleware\Cors::class,
|
||||
];
|
||||
}
|
||||
|
|
18
app/Http/Middleware/Cors.php
Normal file
18
app/Http/Middleware/Cors.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Poniverse\Ponyfm\Http\Middleware;
|
||||
|
||||
use App;
|
||||
|
||||
class Cors {
|
||||
public function handle($request, $next)
|
||||
{
|
||||
if (App::environment('local', 'staging')) {
|
||||
return $next($request)
|
||||
->header('Access-Control-Allow-Origin', '*')
|
||||
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
} else {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ Route::group(['prefix' => 'api/v1', 'middleware' => 'json-exceptions'], function
|
|||
});
|
||||
|
||||
|
||||
Route::group(['prefix' => 'api/web'], function () {
|
||||
Route::group(['prefix' => 'api/web', 'middleware' => 'cors'], function () {
|
||||
Route::post('/alexa', 'Api\Web\AlexaController@handle');
|
||||
|
||||
Route::get('/taxonomies/all', 'Api\Web\TaxonomiesController@getAll');
|
||||
|
|
Loading…
Reference in a new issue