|
|
|
@ -47,26 +47,17 @@ export class WebhookManager {
|
|
|
|
// Enhanced internal Docker URL validation
|
|
|
|
// Enhanced internal Docker URL validation
|
|
|
|
if (process.env.WEBHOOK_URL.startsWith('http://srv-captain--')) {
|
|
|
|
if (process.env.WEBHOOK_URL.startsWith('http://srv-captain--')) {
|
|
|
|
if (!url.port) {
|
|
|
|
if (!url.port) {
|
|
|
|
console.warn('⚠️ Internal Docker URL missing port number - this may cause connection issues');
|
|
|
|
console.warn('Internal Docker URL missing port number - this may cause connection issues');
|
|
|
|
// Auto-fix for common CapRover default port
|
|
|
|
|
|
|
|
if (process.env.PORT) {
|
|
|
|
|
|
|
|
process.env.WEBHOOK_URL = process.env.WEBHOOK_URL.replace(
|
|
|
|
|
|
|
|
'http://srv-captain--',
|
|
|
|
|
|
|
|
`http://srv-captain--:${process.env.PORT}/`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
console.warn(`⚠️ Auto-corrected URL to: ${process.env.WEBHOOK_URL.substring(0, 30)}...`);
|
|
|
|
|
|
|
|
return; // Skip further validation for corrected URL
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Allow internal docker URLs in production
|
|
|
|
// Allow internal docker URLs in production
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
if (!['http:', 'https:', 'http://srv-captain--'].some(prefix =>
|
|
|
|
const isOk = (url.protocol === 'http:' || url.protocol === 'https:') || process.env.WEBHOOK_URL.startsWith('http://srv-captain--');
|
|
|
|
process.env.WEBHOOK_URL?.startsWith(prefix))) {
|
|
|
|
if (!isOk) {
|
|
|
|
console.warn('Production WEBHOOK_URL should use http/https or internal docker URL');
|
|
|
|
console.warn('Production WEBHOOK_URL should use http/https or internal docker URL');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!['http:', 'https:'].includes(url.protocol)) {
|
|
|
|
} else if (!(url.protocol === 'http:' || url.protocol === 'https:')) {
|
|
|
|
throw new Error('WEBHOOK_URL must use http or https protocol');
|
|
|
|
throw new Error('WEBHOOK_URL must use http or https protocol');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
|