From ded69b361e110748a270fd8443ba29584730c278 Mon Sep 17 00:00:00 2001 From: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com> Date: Fri, 20 Jan 2023 01:37:09 +0530 Subject: [PATCH] server: serve local console assets even if console is disabled PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7568 GitOrigin-RevId: ef1548c80280f91aabd94075b658de7d04b8b7a3 --- server/src-lib/Hasura/Server/App.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src-lib/Hasura/Server/App.hs b/server/src-lib/Hasura/Server/App.hs index 45bf0435c5d..d3734e674d1 100644 --- a/server/src-lib/Hasura/Server/App.hs +++ b/server/src-lib/Hasura/Server/App.hs @@ -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) =>