From 71eecb3515928675db65b79fbf970e7dfe524c55 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Tue, 21 Mar 2023 14:04:54 -0500 Subject: [PATCH] chore: embed build info in the html to reduce requests (#6605) This will reduce a request on every page load of Coder! --- site/index.html | 1 + site/site.go | 32 ++++++++++++++----- .../xServices/buildInfo/buildInfoXService.ts | 15 ++++++++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/site/index.html b/site/index.html index 758c347fad..ac18266dcd 100644 --- a/site/index.html +++ b/site/index.html @@ -16,6 +16,7 @@ + { + // Build info is injected by the Coder server into the HTML document. + const buildInfo = document.querySelector("meta[property=build-info]") + if (buildInfo) { + const rawContent = buildInfo.getAttribute("content") + try { + return JSON.parse(rawContent as string) + } catch (ex) { + // Ignore this and fetch as normal! + } + } + + return API.getBuildInfo() + }, }, actions: { assignBuildInfo: assign({