fruitcake / laravel-cors

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
MIT License
6.27k stars 613 forks source link

[Solution] Add exception handler cross domain for laravel 8.x #537

Open CongAn opened 3 years ago

CongAn commented 3 years ago

Add the following code inapp/Exceptions/Handler.php to add cross domain support for all exception error responses in laravel 8. X project.

app/Exceptions/Handler.php 中添加以下代码,可以为laravel 8.x项目中所有异常错误响应添加跨域支持。

    public function render($request, Throwable $e)
    {
        return app('Fruitcake\Cors\HandleCors')
            ->handle($request, fn() => parent::render($request, $e));
    }

I'm very sorry, English is not good, it all depends on translation.

32

ex0nnix commented 3 years ago

Add the following code inapp/Exceptions/Handler.php to add cross domain support for all exception error responses in laravel 8. X project.

app/Exceptions/Handler.php 中添加以下代码,可以为laravel 8.x项目中所有异常错误响应添加跨域支持。

    public function render($request, Throwable $e)
    {
        return app('Fruitcake\Cors\HandleCors')
            ->handle($request, fn() => parent::render($request, $e));
    }

I'm very sorry, English is not good, it all depends on translation.

32

You saved my day.

AntonLugtenburg commented 3 years ago

Thanks buddy