截至昨天,下面的代码有效。然而今天,我必须在 laravel 中运行 php artisan config:cache 命令,因为我添加了一个包,现在我漂亮的 ionic 应用程序不想运行连接到任何东西,因为我不断收到此 403 错误。
在我安装“rap2hpoutre/laravel-log-viewer”:“^0.19.1”并缓存后开始出现错误,但我认为这与它没有任何关系。我很确定我的缓存在此之前是最新的。
jwt 产生相同的错误。
以前,该应用程序无需 cors 插件即可运行。
它在本地和我的服务器上向我提供了此错误(因为我也必须在那里缓存)。
这个错误与我之前调试时遇到的错误不同。
当我在 chrome 中正常拉取路线http://xxx/api/home时- 它返回正常...在邮递员中相同
感谢您的帮助!
错误
选项http://xxx/api/home 403(禁止)无法加载http://xxx/api/home:预检响应没有 HTTP 正常状态。
离子
basicGet_no_token(rl){
console.log('basicGet - ' + this.base_url + rl);
return new Promise((resolve, reject) => {
this.http.get(this.base_url + rl,
{headers: new HttpHeaders({
'Content': 'application/json',
'Accept': 'application/json',
})})
.subscribe(res => {console.log(res);resolve(res);}, (err) => {this.handleError(err);console.log(err);reject(err);});
});
}
Run Code Online (Sandbox Code Playgroud)
拉拉维尔
Route::group(['middleware' => ['addHeaders']], function () {
Route::get('home', 'api\WelcomeController@home');
});
class addHeaders …Run Code Online (Sandbox Code Playgroud) 在我的Laravel 5.4生产服务器上,我忘记在实现多授权系统后运行php artisan config:cache命令.这一切都在我的开发环境中工作,但它不想在生产中.自从运行缓存命令以来,我已经解决了所有错误.但是我坚持这个,真的不知道该把它带到哪里.我没有提供任何信息,请随时提出,我会发布.非常感谢你的帮助.
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
public function report(Exception $exception)
{
parent::report($exception);
}
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return …Run Code Online (Sandbox Code Playgroud)