server: serve local console assets even if console is disabled

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7568
GitOrigin-RevId: ef1548c80280f91aabd94075b658de7d04b8b7a3
This commit is contained in:
Rikin Kachhia 2023-01-20 01:37:09 +05:30 committed by hasura-bot
parent 37a15c25e8
commit ded69b361e

View File

@ -899,6 +899,9 @@ httpApp setupHook corsCfg serverCtx enableConsole consoleAssetsDir consoleSentry
-- API Console and Root Dir
when (enableConsole && enableMetadata) serveApiConsole
-- Local console assets for server and CLI consoles
serveApiConsoleAssets
-- Health check endpoint with logs
let healthzAction = do
let errorMsg = "ERROR"
@ -1127,11 +1130,6 @@ httpApp setupHook corsCfg serverCtx enableConsole consoleAssetsDir consoleSentry
-- redirect / to /console
Spock.get Spock.root $ Spock.redirect "console"
-- serve static files if consoleAssetsDir is set
for_ consoleAssetsDir $ \dir ->
Spock.get ("console/assets" <//> Spock.wildcard) $ \path -> do
consoleAssetsHandler logger (scLoggingSettings serverCtx) dir (T.unpack path)
-- serve console html
Spock.get ("console" <//> Spock.wildcard) $ \path -> do
req <- Spock.request
@ -1140,6 +1138,12 @@ httpApp setupHook corsCfg serverCtx enableConsole consoleAssetsDir consoleSentry
consoleHtml <- lift $ renderConsole path authMode enableTelemetry consoleAssetsDir consoleSentryDsn
either (raiseGenericApiError logger (scLoggingSettings serverCtx) headers . internalError . T.pack) Spock.html consoleHtml
serveApiConsoleAssets = do
-- serve static files if consoleAssetsDir is set
for_ consoleAssetsDir $ \dir ->
Spock.get ("console/assets" <//> Spock.wildcard) $ \path -> do
consoleAssetsHandler logger (scLoggingSettings serverCtx) dir (T.unpack path)
raiseGenericApiError ::
forall m.
(MonadIO m, HttpLog m) =>