Adjusted CORS handling for emoticon endpoint.

This commit is contained in:
flash 2024-01-17 19:57:46 +00:00
parent f0fc735975
commit 77eadd5bde

View file

@ -37,10 +37,15 @@ final class SharpChatRoutes implements IRouteHandler {
Route::handleAttributes($router, $this);
}
#[Route('OPTIONS', '/_sockchat/emotes')]
#[Route('GET', '/_sockchat/emotes')]
public function getEmotes($response, $request): array {
public function getEmotes($response, $request): array|int {
$response->setHeader('Access-Control-Allow-Origin', '*');
$response->setHeader('Access-Control-Allow-Methods', 'GET');
$response->setHeader('Access-Control-Allow-Headers', 'Cache-Control');
if($request->getMethod() === 'OPTIONS')
return 204;
$emotes = $this->emotes->getEmotes(orderBy: 'order');
$out = [];