0
當我嘗試在handle()函數內部使用$ request-> all()時,Laravel 5.2中的我的Auth中間件返回null。
這裏是我的路線聲明:
Route::group(['middleware' => ['web', 'auth.origin']], function() {
Route::get('/', function() {
return view('welcome');
});
Route::post('identity', ['uses' => '[email protected]']);
});
/**
* Handle an incoming request. Authenticates a request to make sure
* it's origin matches the allowed request origins.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle ($request, Closure $next)
{
dd($request->all()); die;
return $next($request);
$accountId = $request->input('accountId');
if(in_array($accountId, self::$origin)) {
if(in_array($request->getHttpHost(), self::$origin[$accountId])) {
return $next($request);
}
}
else {
return response('Unauthorized', 401);
}
}
然而,當我調用$請求 - >所有()方法我的控制器內,它返回的數組,如果值。
我從客戶端發送JSON請求。
請幫忙。
哇對不起,沒看出來是中間件直到現在。但是如果有數據發送,它應該出現在$ request中。你可以嘗試添加一個Get Request來查看它是否仍然是空的?只需在您的地址上添加'?key = value'即可。 –
「客戶的JSON請求」是什麼意思,客戶在這裏意味着什麼? – Qazi
'客戶端'是這裏的瀏覽器或通過另一臺服務器的API調用。 –