diff --git a/src/SharpChat/SharpChatRoutes.php b/src/SharpChat/SharpChatRoutes.php index c2bbfc5..5273814 100644 --- a/src/SharpChat/SharpChatRoutes.php +++ b/src/SharpChat/SharpChatRoutes.php @@ -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 = [];