From 82844c5e4294155d9f562250880e8524f00c8c9b Mon Sep 17 00:00:00 2001 From: ariqbasyar <ariqbasyar2@gmail.com> Date: Mon, 7 Dec 2020 15:48:14 +0700 Subject: [PATCH] response headers for cors --- src/Lib.hs | 2 ++ src/Response.hs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Lib.hs b/src/Lib.hs index eb5a042..d86992c 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -20,6 +20,7 @@ handler Request {..} context = do Right Response { statusCode = 200, + headers = object ["Access-Control-Allow-Origin" .= ("*" :: String)], body = minimax game } Nothing -> @@ -27,5 +28,6 @@ handler Request {..} context = do Right Response { statusCode = 400, + headers = object ["Access-Control-Allow-Origin" .= ("*" :: String)], body = "invalid game" } diff --git a/src/Response.hs b/src/Response.hs index 7e304fd..d0da7a1 100644 --- a/src/Response.hs +++ b/src/Response.hs @@ -8,6 +8,7 @@ import GHC.Generics data Response = Response { statusCode :: Int, + headers :: Value, body :: String } deriving (Generic, ToJSON) -- GitLab