@@ -70,6 +70,7 @@ import Protolude hiding (Proxy, toList)
7070
7171data AppConfig = AppConfig
7272 { configAppSettings :: [(Text , Text )]
73+ , configCorsAllowedOrigins :: Maybe [Text ]
7374 , configDbAnonRole :: Maybe BS. ByteString
7475 , configDbChannel :: Text
7576 , configDbChannelEnabled :: Bool
@@ -139,7 +140,8 @@ toText conf =
139140 where
140141 -- apply conf to all pgrst settings
141142 pgrstSettings = (\ (k, v) -> (k, v conf)) <$>
142- [(" db-anon-role" , q . T. decodeUtf8 . fromMaybe " " . configDbAnonRole)
143+ [(" cors-allowed-origins" , q . maybe " *" (T. intercalate " ," ) . configCorsAllowedOrigins)
144+ ,(" db-anon-role" , q . T. decodeUtf8 . fromMaybe " " . configDbAnonRole)
143145 ,(" db-channel" , q . configDbChannel)
144146 ,(" db-channel-enabled" , T. toLower . show . configDbChannelEnabled)
145147 ,(" db-extra-search-path" , q . T. intercalate " ," . configDbExtraSearchPath)
@@ -233,6 +235,7 @@ parser :: Maybe FilePath -> Environment -> [(Text, Text)] -> RoleSettings -> Rol
233235parser optPath env dbSettings roleSettings roleIsolationLvl =
234236 AppConfig
235237 <$> parseAppSettings " app.settings"
238+ <*> (fmap splitOnCommas <$> optValue " cors-allowed-origins" )
236239 <*> (fmap encodeUtf8 <$> optString " db-anon-role" )
237240 <*> (fromMaybe " pgrst" <$> optString " db-channel" )
238241 <*> (fromMaybe True <$> optBool " db-channel-enabled" )
0 commit comments