Add proxy awareness for OpenAPI spec generation
Proxy uri from command line options takes precedence over host and port
This commit is contained in:
@@ -8,6 +8,7 @@ import PostgREST.Config (AppConfig (..),
|
||||
minimumPgVersion,
|
||||
prettyVersion,
|
||||
readOptions)
|
||||
import PostgREST.OpenAPI (isMalformedProxyUri)
|
||||
import PostgREST.DbStructure
|
||||
|
||||
import Control.Monad
|
||||
@@ -50,12 +51,16 @@ main = do
|
||||
conf <- readOptions
|
||||
let host = configHost conf
|
||||
port = configPort conf
|
||||
proxy = configProxyUri conf
|
||||
pgSettings = cs (configDatabase conf)
|
||||
appSettings = setHost (fromString host)
|
||||
. setPort port
|
||||
. setServerName (cs $ "postgrest/" <> prettyVersion)
|
||||
$ defaultSettings
|
||||
|
||||
when (isMalformedProxyUri proxy) $ error
|
||||
"Malformed proxy uri, a correct example: https://example.com:8443/basePath"
|
||||
|
||||
unless (secret "secret" /= configJwtSecret conf) $
|
||||
putStrLn "WARNING, running in insecure mode, JWT secret is the default value"
|
||||
Prelude.putStrLn $ "Listening on port " ++
|
||||
|
||||
Reference in New Issue
Block a user