Skip to content

Commit

Permalink
feat(client): Add /health endpoint to the client app
Browse files Browse the repository at this point in the history
  • Loading branch information
alepefe committed Nov 22, 2024
1 parent 4afadea commit 9d27581
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions client/src/app/local-api/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { env } from "@/env.mjs";

export async function GET() {
try {
const res = await fetch(env.NEXT_PUBLIC_API_URL + "/health", {
cache: "no-cache",
});
if (res.status === 200) {
return new Response("OK", {
status: 200,
headers: { "Cache-Control": "max-age=5, must-revalidate" },
});
} else {
return new Response("KO", {
status: 503,
headers: { "Cache-Control": "max-age=5, must-revalidate" },
});
}
} catch (error) {
return new Response("KO", {
status: 503,
headers: { "Cache-Control": "max-age=5, must-revalidate" },
});
}
}
2 changes: 1 addition & 1 deletion client/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ function isAuthenticated(req: NextRequest) {

// Step 3. Configure "Matching Paths" below to protect routes with HTTP Basic Auth
export const config = {
matcher: "/((?!api|_next/static|_next/image|favicon.ico).*)",
matcher: "/((?!local-api|_next/static|_next/image|favicon.ico).*)",
};
2 changes: 1 addition & 1 deletion infrastructure/v2/modules/beanstalk/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ locals {
{
namespace = "aws:elasticbeanstalk:environment:process:default"
name = "HealthCheckPath"
value = "/health"
value = "/local-apì/health"
}
]
}
Expand Down

0 comments on commit 9d27581

Please sign in to comment.