use origin instead of host

This commit is contained in:
Keagan McClelland
2020-12-10 17:27:42 -07:00
committed by Aiden McClelland
parent 7ce276c267
commit 0f43e5282f

View File

@@ -55,6 +55,8 @@ import Handler.Status
import Handler.Wifi
import Handler.V0
import Settings
import Network.HTTP.Types.Header ( hOrigin )
import Data.List (lookup)
-- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
@@ -65,7 +67,7 @@ instance YesodSubDispatch Auth AgentCtx where
yesodSubDispatch = $(mkYesodSubDispatch resourcesAuth)
dynamicCorsResourcePolicy :: Request -> Maybe CorsResourcePolicy
dynamicCorsResourcePolicy req = Just . policy $ requestHeaderHost req
dynamicCorsResourcePolicy req = Just . policy . lookup hOrigin $ requestHeaders req
where
policy o = simpleCorsResourcePolicy
{ corsOrigins = (\o' -> ([o'], True)) <$> o