app: make _healthz a real API route, match on k8s healthcheck user-agent
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
0dabe6e399
commit
de9f968d78
14
app/_healthz/route.ts
Normal file
14
app/_healthz/route.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export const GET = async (req: NextRequest) => {
|
||||
if (req.headers.get("user-agent") !== "healthz") {
|
||||
return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
return new Response("OK", {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
});
|
||||
};
|
@ -47,9 +47,7 @@ spec:
|
||||
path: /_healthz
|
||||
port: 3000
|
||||
httpHeaders:
|
||||
- name: x-real-ip
|
||||
value: "100.100.100.100"
|
||||
- name: user-agent
|
||||
value: "Kubernetes healthchecks"
|
||||
value: "healthz"
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 3
|
@ -1 +0,0 @@
|
||||
OK
|
Loading…
x
Reference in New Issue
Block a user