File size: 545 Bytes
657f281 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function publicHost() {
return String(process.env.WEBHOOK_HOST || process.env.SPACE_HOST || process.env.PORTAL_HOST || '')
.replace(/^https?:\/\//, '')
.replace(/\/+$/, '');
}
function snippeWebhookUrl(path = '/api/webhooks/snippe') {
const host = publicHost();
if (!host) {
throw new Error('WEBHOOK_HOST, SPACE_HOST, or PORTAL_HOST is required for Snippe webhooks');
}
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
return `https://${host}${normalizedPath}`;
}
module.exports = { snippeWebhookUrl };
|