mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: embed build info in the html to reduce requests (#6605)
This will reduce a request on every page load of Coder!
This commit is contained in:
@@ -53,7 +53,20 @@ export const buildInfoMachine = createMachine(
|
||||
},
|
||||
{
|
||||
services: {
|
||||
getBuildInfo: API.getBuildInfo,
|
||||
getBuildInfo: async () => {
|
||||
// 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({
|
||||
|
||||
Reference in New Issue
Block a user