better integration with Kubernetes healthcheck
Describe the feature
When we try to host our nuxt3 + nuxt-auth project in kubernetes, we run into the following problem:
For kubernetes, we need a healthcheck which responds with 200 if the application is up. This healthcheck must be provided before nuxt-auth is initialized, since nuxt-auth returns 503 until it is able to reach the own hostname.
In kubernetes, the own hostname is reachable, if the healthcheck is successful.
This is now a chicken-egg problem, nuxt-auth cannot initialize correctly as the hostname is not assigned to the container, but kubernetes does not assign the hostname as the application is not correctly initialized.
How would you implement this?
It would be great to have a healthckech route provided this package that returns 200 status even before nuxt-auth is fully initialized. If we just add a simple healthcheck server middleware, that still returns 503 as the nuxt-auth package itself returns 503.
Additional information
- [ ] Would you be willing to help implement this feature?
Provider
- [ ] AuthJS
- [ ] Local
- [ ] Refresh
- [ ] New Provider
Could you share a bit about your setup? I don't quite understand why a startup or readiness probe would need to interact with authentication state
Hi @hirisov 👋
We also use this health check for our Kubernetes applications. In our case we just created a non-protected API route that we then defined as our health check URL.
// file: ~/server/api/health.get.ts
const startupTime = new Date()
export default defineEventHandler(() => ({
status: 'healthy',
time: new Date(),
startupTime,
version: useRuntimeConfig().version
}))
Is this possible to do in your setup?
Returning 200 from e.g. a client-side route (such as the index page) for a health check would not be the solution here in my opinion. If we returned 200, even though the page was protected, this would be a "lie", as the response code should be 401 and not 200.
@hirisov Is this issue solved for you?