From e00752a75446ee665668181c8634dc6a59eb9657 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Dec 2023 13:31:30 +0100 Subject: [PATCH] fix: don't crash vite when oCIS is not available (#10173) --- vite.config.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 919a403a108..0590d8dde9f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -255,9 +255,16 @@ export default defineConfig(async ({ mode, command }) => { configureServer(server: ViteDevServer) { server.middlewares.use(async (request, response, next) => { if (request.url === '/config.json') { - response.statusCode = 200 - response.setHeader('Content-Type', 'application/json') - response.end(JSON.stringify(await getConfigJson(configUrl, config))) + try { + const configJson = await getConfigJson(configUrl, config) + response.statusCode = 200 + response.setHeader('Content-Type', 'application/json') + response.end(JSON.stringify(configJson)) + } catch (e) { + response.statusCode = 502 + response.setHeader('Content-Type', 'application/json') + response.end(JSON.stringify(e)) + } return } next()