From 9b477aaf9216ebde00fffc47a34dbdf59d8f5865 Mon Sep 17 00:00:00 2001 From: Bart Stefanski Date: Fri, 21 Apr 2023 12:36:14 +0200 Subject: [PATCH] chore: setup google & kube z-pages health endpoint --- next.config.js | 8 ++++++++ pages/api/health.ts | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 pages/api/health.ts diff --git a/next.config.js b/next.config.js index 14b6e1f..113fd61 100644 --- a/next.config.js +++ b/next.config.js @@ -10,4 +10,12 @@ const withPlugins = require("next-compose-plugins") module.exports = withPlugins([[withBundleAnalyzer]], { reactStrictMode: true, experimental: { instrumentationHook: true }, + rewrites() { + return [ + { source: "/healthz", destination: "/api/health" }, + { source: "/api/healthz", destination: "/api/health" }, + { source: "/health", destination: "/api/health" }, + { source: "/ping", destination: "/api/health" }, + ] + }, }) diff --git a/pages/api/health.ts b/pages/api/health.ts new file mode 100644 index 0000000..05fda7d --- /dev/null +++ b/pages/api/health.ts @@ -0,0 +1,5 @@ +import { NextApiRequest, NextApiResponse } from "next" + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + res.status(200).json({ status: "ok" }) +}