From 0204bdab5592630beb64201aa3cbe111f36efb1b Mon Sep 17 00:00:00 2001 From: Luminessa Starlight Date: Mon, 20 Oct 2025 11:46:37 -0400 Subject: [PATCH] Frontend service: Update boot failure request to GET (#112603) * update boot failure request to GET, add notes about why/how * remove now unused function * remove unneeded header --- pkg/services/frontend/frontend_service.go | 9 +++------ pkg/services/frontend/index.html | 16 +++++++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/pkg/services/frontend/frontend_service.go b/pkg/services/frontend/frontend_service.go index d1e343dede7..34acee7b0c7 100644 --- a/pkg/services/frontend/frontend_service.go +++ b/pkg/services/frontend/frontend_service.go @@ -127,11 +127,6 @@ func (s *frontendService) routeGet(m *web.Mux, pattern string, h ...web.Handler) m.Get(pattern, handlers...) } -func (s *frontendService) routePost(m *web.Mux, pattern string, h ...web.Handler) { - handlers := append([]web.Handler{middleware.ProvideRouteOperationName(pattern)}, h...) - m.Post(pattern, handlers...) -} - // Apply the same middleware patterns as the main HTTP server func (s *frontendService) addMiddlewares(m *web.Mux) { loggermiddleware := loggermw.Provide(s.cfg, s.features) @@ -164,7 +159,9 @@ func (s *frontendService) registerRoutes(m *web.Mux) { }) // Frontend boot error reporting endpoint - s.routePost(m, "/-/fe-boot-error", s.handleBootError) + // GET because all POST requests are passed to the backend, even though POST is more correct. The frontend + // uses cache busting to ensure requests aren't cached. + s.routeGet(m, "/-/fe-boot-error", s.handleBootError) // All other requests return index.html s.routeGet(m, "/*", s.index.HandleRequest) diff --git a/pkg/services/frontend/index.html b/pkg/services/frontend/index.html index 9f5b5d48dba..f937a987ca4 100644 --- a/pkg/services/frontend/index.html +++ b/pkg/services/frontend/index.html @@ -174,15 +174,13 @@ document.querySelector('.fs-variant-loader').classList.add('fs-hidden'); document.querySelector('.fs-variant-error').classList.remove('fs-hidden'); - // Report the error to the backend - const errorMessage = err ? err.message : 'Unknown error'; - - fetch('/-/fe-boot-error', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: errorMessage, + // not a secure random value, but collisions are highly unlikely and 1/1000_000_000 lost requests + // doesn't make a difference. + fetch(`/-/fe-boot-error?ts=${Date.now()}${Math.random()}`, { + // This "should" be a POST request, but we must use GET to interact with the correct service. + // no-store and ?ts=_ are used to ensure the request isn't cached. + method: 'GET', + cache: "no-store", }).catch(err => { console.error('Failed to report boot error to backend: ', err); });