遇到一个奇葩的问题
用laravel5.1作web端(称作A),API端也是用laravel5做的一个简单的接口端(称作B),然后A用php-curl-class去做请求
$res = $this->curlPostWithoutToken('auth/login', $request->only('username', 'password'));
$url = config('api.apiUrl').$url;
$curl = new Curl();
$curl->setUserAgent('');
$curl->setReferrer('');
foreach ($header as $key => $value) {
$curl->setHeader($key, $value);
}
$curl->setCookie('key', 'value');
$curl->post($url, $data);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;exit;
}
return $curl->response;
这是B端的login代码:
$credentials = $request->only('username', 'password');
//return $this->successResponse($credentials);
try {
// attempt to verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
return $this->errorResponse(Status::RET_ACCOUNT_WRONG);
}
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return $this->errorResponse(Status::RET_COUNT_NOT_CREATE);
}
// all good so return the token
return response()->json(compact('token'));
这样就出现了一个奇葩的问题,A去作的请求,但是B端却是用我A端的数据里User表去做的验证,而且如果A端不配置数据库,就会报错,反正一句话,就是A去请求B,B却是用的A端的数据库,这种问题谁有遇到过。。。。。
推荐文章: