When building with dev flag, disable the approot host check middleware

This allows to browse via e.g. localhost:3000 even if the instance host is
something else and the rendered URLs don't have a port number. It still makes
many things impossible or inconvenient, but at least you can launch Vervis
locally for development and see pages. Right now even CSS doesn't work because
of the URLs not matching the actual localhost:3000 access. Maybe gradually I'll
figure it out.
This commit is contained in:
fr33domlover 2019-06-14 17:36:31 +00:00
parent f8f3a31a8d
commit 698059763a
2 changed files with 18 additions and 12 deletions

View file

@ -193,7 +193,10 @@ instance Yesod App where
defaultCsrfHeaderName
defaultCsrfParamName
)
. ( \ handler -> do
. ( \ handler ->
if developmentMode
then handler
else do
host <- getsYesod $ appInstanceHost . appSettings
bs <- lookupHeaders hHost
case bs of

View file

@ -164,14 +164,17 @@ data AppSettings = AppSettings
, appHighlightStyle :: Text
}
instance FromJSON AppSettings where
parseJSON = withObject "AppSettings" $ \ o -> do
let defaultDev =
developmentMode :: Bool
developmentMode =
#if DEVELOPMENT
True
#else
False
#endif
instance FromJSON AppSettings where
parseJSON = withObject "AppSettings" $ \ o -> do
let defaultDev = developmentMode
appStaticDir <- o .: "static-dir"
appDatabaseConf <- o .: "database"
appMaxInstanceKeys <- o .:? "max-instance-keys"