Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Adds CORS headers to Swoole server
Browse files Browse the repository at this point in the history
  • Loading branch information
HazyAlex committed Feb 21, 2022
1 parent 2f6f3b7 commit 480036a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/swoole-server
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ $server->on('request', function ($request, $response) use ($server, $workerState
]);
}

$response->header('Access-Control-Allow-Origin', config('cors.allowed_origins'));
$response->header('Access-Control-Allow-Headers', config('cors.allowed_headers'));
$response->header('Access-Control-Allow-Methods', config('cors.allowed_methods'));

$workerState->worker->handle(...$workerState->client->marshalRequest(new RequestContext([
'swooleRequest' => $request,
'swooleResponse' => $response,
Expand Down

0 comments on commit 480036a

Please sign in to comment.