Alerting/Chore: Mock API (MSW) in browser (#89223)

Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
Tom Ratcliffe
2024-09-04 10:22:03 +01:00
committed by GitHub
parent 636b831d90
commit aec73f3501
9 changed files with 323 additions and 1 deletions

View File

@@ -604,6 +604,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
hs.mapStatic(m, hs.Cfg.StaticRootPath, "build", "public/build")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public", "/public/views/swagger.html")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "robots.txt", "robots.txt")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "mockServiceWorker.js", "mockServiceWorker.js")
if hs.Cfg.ImageUploadProvider == "local" {
hs.mapStatic(m, hs.Cfg.ImagesDir, "", "/public/img/attachments")
@@ -753,6 +754,12 @@ func (hs *HTTPServer) mapStatic(m *web.Mux, rootDir string, dir string, prefix s
}
}
if prefix == "mockServiceWorker.js" {
headers = func(c *web.Context) {
c.Resp.Header().Set("Content-Type", "application/javascript")
}
}
m.Use(httpstatic.Static(
path.Join(rootDir, dir),
httpstatic.StaticOptions{