diff --git a/nginx.conf b/nginx.conf index 69d2155..4bd11a9 100644 --- a/nginx.conf +++ b/nginx.conf @@ -37,6 +37,13 @@ server { access_log off; } + # Health check endpoint + location ~ ^/(health|healthz)$ { + access_log off; + default_type application/json; + return 200 '{"status":"healthy","service":"dashboard"}'; + } + # SPA routing - route all queries to index.html location / { try_files $uri $uri/ /index.html; diff --git a/public/health b/public/health new file mode 100644 index 0000000..258e3d3 --- /dev/null +++ b/public/health @@ -0,0 +1 @@ +{"status":"healthy","service":"dashboard"} diff --git a/vite.config.mjs b/vite.config.mjs index f2bae66..5693bb3 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -5,6 +5,24 @@ import vue from '@vitejs/plugin-vue'; import Components from 'unplugin-vue-components/vite'; import { defineConfig } from 'vite'; +function healthCheckPlugin() { + return { + name: 'vite-plugin-healthcheck', + configureServer(server) { + server.middlewares.use((req, res, next) => { + const url = req.url ? req.url.split('?')[0] : ''; + if (url === '/health' || url === '/healthz') { + res.statusCode = 200; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify({ status: 'healthy', service: 'dashboard' })); + return; + } + next(); + }); + } + }; +} + // https://vitejs.dev/config/ export default defineConfig({ optimizeDeps: { @@ -14,7 +32,8 @@ export default defineConfig({ vue(), Components({ resolvers: [PrimeVueResolver()] - }) + }), + healthCheckPlugin() ], resolve: { alias: {