处理跨域用的官方的barryvdh/laravel-cors
包,但试了下 HttpException 的 header 属性上写死加上Access-Control-Allow-Origin'=>'*'
还是不行。
namespace Symfony\Component\HttpKernel\Exception;
/**
* HttpException.
*
* @author Kris Wallsmith <[email protected]>
*/
class HttpException extends \RuntimeException implements HttpExceptionInterface
{
private $statusCode;
private $headers;
public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0)
{
$this->statusCode = $statusCode;
$this->headers = ['Access-Control-Allow-Origin'=>'*'];
parent::__construct($message, $code, $previous);
}
1
jswh 2019-07-18 15:56:04 +08:00
找到 ExceptionHandler,去哪里改 render 函数,加上 header
|