Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8cf1e84

Browse files
authored
chore: ensure root handler has sudomain app mw (#12812)
Enterprise routes like scim touch this.
1 parent b785e99 commit 8cf1e84

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

coderd/coderd.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ func New(options *Options) *API {
648648
httpmw.CSRF(options.SecureAuthCookie),
649649
)
650650

651+
// This incurs a performance hit from the middleware, but is required to make sure
652+
// we do not override subdomain app routes.
653+
r.Get("/latency-check", tracing.StatusWriterMiddleware(prometheusMW(LatencyCheck())).ServeHTTP)
654+
651655
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })
652656

653657
// Attach workspace apps routes.
@@ -1192,15 +1196,7 @@ func New(options *Options) *API {
11921196
// static files since it only affects browsers.
11931197
r.NotFound(cspMW(compressHandler(httpmw.HSTS(api.SiteHandler, options.StrictTransportSecurityCfg))).ServeHTTP)
11941198

1195-
// This must be before all middleware to improve the response time.
1196-
// So make a new router, and mount the old one as the root.
1197-
rootRouter := chi.NewRouter()
1198-
// This is the only route we add before all the middleware.
1199-
// We want to time the latency of the request, so any middleware will
1200-
// interfere with that timing.
1201-
rootRouter.Get("/latency-check", tracing.StatusWriterMiddleware(prometheusMW(LatencyCheck())).ServeHTTP)
1202-
rootRouter.Mount("/", r)
1203-
api.RootHandler = rootRouter
1199+
api.RootHandler = r
12041200

12051201
return api
12061202
}

0 commit comments

Comments
 (0)