Merge pull request #426 from Crossbell-Box/feat/healthcheck
feat: healthcheck api
This commit is contained in:
commit
bc6d3db272
|
|
@ -48,10 +48,11 @@ spec:
|
|||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
httpGet:
|
||||
path: /api/healthcheck
|
||||
port: 3000
|
||||
initialDelaySeconds: 40
|
||||
periodSeconds: 10
|
||||
periodSeconds: 20
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: 3000
|
||||
|
|
|
|||
|
|
@ -64,10 +64,11 @@ spec:
|
|||
- name: xlog-image
|
||||
mountPath: /app/.next/cache/images
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
httpGet:
|
||||
path: /api/healthcheck
|
||||
port: 3000
|
||||
initialDelaySeconds: 40
|
||||
periodSeconds: 10
|
||||
periodSeconds: 20
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: 3000
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@ import { NextRequest, NextResponse } from "next/server"
|
|||
import { IS_PROD } from "~/lib/constants"
|
||||
import { DISCORD_LINK } from "~/lib/env"
|
||||
|
||||
// HTTPWhiteListPaths: White list of path for plain http request, no HTTPS redirect
|
||||
const HTTPWhitelistPaths = [
|
||||
"/api/healthcheck",
|
||||
]
|
||||
|
||||
export default async function middleware(req: NextRequest) {
|
||||
const { pathname } = req.nextUrl
|
||||
|
||||
if (IS_PROD && req.headers.get("x-forwarded-proto") !== "https") {
|
||||
if (IS_PROD && req.headers.get("x-forwarded-proto") !== "https" && !HTTPWhitelistPaths.includes(req.nextUrl.pathname)) {
|
||||
let cfHttps = false
|
||||
try {
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
export default async function healthcheck(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
) {
|
||||
res.status(200).json({
|
||||
ok: true,
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue