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

Skip to content

Commit 50ad4a8

Browse files
authored
fix: use backend for /healthz page (#4938)
1 parent bda7636 commit 50ad4a8

File tree

7 files changed

+18
-36
lines changed

7 files changed

+18
-36
lines changed

coderd/coderd.go

+2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ func New(options *Options) *API {
233233
httpmw.CSRF(options.SecureAuthCookie),
234234
)
235235

236+
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })
237+
236238
apps := func(r chi.Router) {
237239
r.Use(
238240
tracing.Middleware(api.TracerProvider),

coderd/coderd_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package coderd_test
22

33
import (
44
"context"
5+
"io"
56
"net/http"
67
"net/netip"
78
"strconv"
@@ -114,3 +115,17 @@ func TestDERPLatencyCheck(t *testing.T) {
114115
defer res.Body.Close()
115116
require.Equal(t, http.StatusOK, res.StatusCode)
116117
}
118+
func TestHealthz(t *testing.T) {
119+
t.Parallel()
120+
client := coderdtest.New(t, nil)
121+
122+
res, err := client.Request(context.Background(), http.MethodGet, "/healthz", nil)
123+
require.NoError(t, err)
124+
defer res.Body.Close()
125+
126+
require.Equal(t, http.StatusOK, res.StatusCode)
127+
body, err := io.ReadAll(res.Body)
128+
require.NoError(t, err)
129+
130+
assert.Equal(t, "OK", string(body))
131+
}

coderd/coderdtest/authorize.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
3737

3838
assertRoute := map[string]RouteCheck{
3939
// These endpoints do not require auth
40+
"GET:/healthz": {NoAuthorize: true},
4041
"GET:/api/v2": {NoAuthorize: true},
4142
"GET:/api/v2/buildinfo": {NoAuthorize: true},
4243
"GET:/api/v2/users/first": {NoAuthorize: true},

site/e2e/pom/HealthzPage.ts

-13
This file was deleted.

site/e2e/tests/healthz.spec.ts

-11
This file was deleted.

site/src/AppRouter.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const NotFoundPage = lazy(() => import("./pages/404Page/404Page"))
3030
const CliAuthenticationPage = lazy(
3131
() => import("./pages/CliAuthPage/CliAuthPage"),
3232
)
33-
const HealthzPage = lazy(() => import("./pages/HealthzPage/HealthzPage"))
3433
const AccountPage = lazy(
3534
() => import("./pages/UserSettingsPage/AccountPage/AccountPage"),
3635
)
@@ -107,7 +106,6 @@ export const AppRouter: FC = () => {
107106

108107
<Route path="login" element={<LoginPage />} />
109108
<Route path="setup" element={<SetupPage />} />
110-
<Route path="healthz" element={<HealthzPage />} />
111109
<Route
112110
path="cli-auth"
113111
element={

site/src/pages/HealthzPage/HealthzPage.tsx

-10
This file was deleted.

0 commit comments

Comments
 (0)