Skip to content

Commit 152fcce

Browse files
committed
cross domain
1 parent b14aa9a commit 152fcce

File tree

6 files changed

+353
-179
lines changed

6 files changed

+353
-179
lines changed

app/Http/Kernel.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ class Kernel extends HttpKernel
3333

3434
'api' => [
3535
'throttle:60,1',
36-
],
37-
'backend' => [
38-
'throttle:60,1',
39-
'jwt_token'
40-
],
36+
'cross_domain'
37+
]
4138
];
4239

4340
/**
@@ -54,5 +51,6 @@ class Kernel extends HttpKernel
5451
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
5552
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
5653
'jwt_token' => \App\Http\Middleware\AuthenticateBackend::class,
54+
'cross_domain' => \App\Http\Middleware\CrossDomain::class,
5755
];
5856
}

app/Http/Middleware/CrossDomain.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Closure;
6+
7+
class CrossDomain
8+
{
9+
/**
10+
* Handle an incoming request.
11+
*
12+
* @param \Illuminate\Http\Request $request
13+
* @param \Closure $next
14+
* @return mixed
15+
*/
16+
public function handle($request, Closure $next)
17+
{
18+
$response = $next($request);
19+
$response->header('Access-Control-Allow-Origin','*');
20+
return $response;
21+
}
22+
}

app/Http/routes.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
});
3636

3737

38-
Route::group(['namespace' => 'Backend', 'prefix' => 'backend'], function () {
38+
Route::group(['namespace' => 'Backend', 'prefix' => 'backend','middleware'=>'api'], function () {
3939

4040
Route::post('login', 'AuthController@postLogin');
4141
Route::post('logout', 'AuthController@postLogout');
4242
Route::post('upload', 'CommonController@upload');
4343

44-
Route::group(['middleware' => ['backend']], function () {
44+
Route::group(['middleware' => ['jwt_token']], function () {
4545

4646
Route::get('dashboard', 'DashboardController@index');
4747
Route::get('admin_info', 'AdminController@getAdminByToken');

0 commit comments

Comments
 (0)