Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions infra/dataform-service/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ async function mainHandler (req, res) {

if (path === '/health') {
// Health check endpoint
const allowedIps = ['127.0.0.1', '::ffff:127.0.0.1', '::1']
const clientIp = req.ip || req.socket?.remoteAddress
const userAgent = req.headers['user-agent'] || ''

// Allow local IPs or Google's health check agent
const isLocal = allowedIps.includes(clientIp)
const isGoogleHC = userAgent.includes('GoogleHC')

if (!isLocal && !isGoogleHC) {
res.status(403).json({
error: 'Forbidden',
message: 'Access to health check endpoint is restricted'
})
return
}

res.status(200).json({
status: 'healthy',
timestamp: new Date().toISOString()
Expand Down