Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: allow cross domain queries. wildcard CORS. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/hercules.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ library
, text
, time
, wai
, wai-cors
, wai-extra
, warp
, wl-pprint-text
Expand Down
4 changes: 3 additions & 1 deletion backend/src/Hercules/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Data.Monoid ((<>))
import Data.Text
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.Cors (simpleCors)
import Network.Wai.Middleware.RequestLogger
import Safe (headMay)
import Servant
Expand All @@ -36,6 +37,7 @@ import Hercules.Query.Hydra
import Hercules.ServerEnv
import Hercules.Static

-- | start Application. No restriction on cross-domain (CORS allow *)
startApp :: Config -> IO ()
startApp config = do
let authenticators = configAuthenticatorList config
Expand All @@ -46,7 +48,7 @@ startApp config = do
Just env -> do
T.putStrLn $ "Serving on http://" <> configHostname config
<> ":" <> (pack . show $ port)
run port . logging =<< app env
run port . (logging . simpleCors) =<< app env

loggingMiddleware :: Config -> Middleware
loggingMiddleware config = case configAccessLogLevel config of
Expand Down