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:
parent
f8f3a31a8d
commit
698059763a
2 changed files with 18 additions and 12 deletions
|
@ -193,12 +193,15 @@ instance Yesod App where
|
|||
defaultCsrfHeaderName
|
||||
defaultCsrfParamName
|
||||
)
|
||||
. ( \ handler -> do
|
||||
host <- getsYesod $ appInstanceHost . appSettings
|
||||
bs <- lookupHeaders hHost
|
||||
case bs of
|
||||
[b] | b == encodeUtf8 host -> handler
|
||||
_ -> invalidArgs [hostMismatch host bs]
|
||||
. ( \ handler ->
|
||||
if developmentMode
|
||||
then handler
|
||||
else do
|
||||
host <- getsYesod $ appInstanceHost . appSettings
|
||||
bs <- lookupHeaders hHost
|
||||
case bs of
|
||||
[b] | b == encodeUtf8 host -> handler
|
||||
_ -> invalidArgs [hostMismatch host bs]
|
||||
)
|
||||
. defaultYesodMiddleware
|
||||
where
|
||||
|
|
|
@ -164,14 +164,17 @@ data AppSettings = AppSettings
|
|||
, appHighlightStyle :: Text
|
||||
}
|
||||
|
||||
developmentMode :: Bool
|
||||
developmentMode =
|
||||
#if DEVELOPMENT
|
||||
True
|
||||
#else
|
||||
False
|
||||
#endif
|
||||
|
||||
instance FromJSON AppSettings where
|
||||
parseJSON = withObject "AppSettings" $ \ o -> do
|
||||
let defaultDev =
|
||||
#if DEVELOPMENT
|
||||
True
|
||||
#else
|
||||
False
|
||||
#endif
|
||||
let defaultDev = developmentMode
|
||||
appStaticDir <- o .: "static-dir"
|
||||
appDatabaseConf <- o .: "database"
|
||||
appMaxInstanceKeys <- o .:? "max-instance-keys"
|
||||
|
|
Loading…
Reference in a new issue