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

Commit

Permalink
Merge pull request #74 from HazyAlex/feature/cors
Browse files Browse the repository at this point in the history
Adds CORS headers to Swoole server
  • Loading branch information
butschster authored Feb 22, 2022
2 parents 2f6f3b7 + 480036a commit 4bad230
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 4bad230

Please sign in to comment.