跨域访问

$origin = $request->server('HTTP_ORIGIN') ? $request->server('HTTP_ORIGIN') : '';
$allow_origin = ['http://localhost:8000',];
$response->header('Access-Control-Allow-Origin', $origin);
$response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN, X-TOKEN, X-OrgCode');
$response->header('Access-Control-Expose-Headers', 'Authorization, authenticated, Content-Disposition');
$response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
$response->header('Access-Control-Allow-Credentials', 'true');
posted @ 2023-07-20 18:17  dunkbird  阅读(12)  评论(1编辑  收藏  举报