Add public MQTT broker URL configuration for email templates

The MQTT broker URL in credential emails was using the internal Docker
address (mqtt://mosquitto:1883) which is not accessible from external
OwnTracks apps. Added MQTT_PUBLIC_BROKER_URL environment variable to
configure the publicly accessible broker address for client apps.

Changes:
- Add MQTT_PUBLIC_BROKER_URL to .env.example with documentation
- Update send-credentials route to use public URL with fallback
- Maintain backward compatibility with existing MQTT_BROKER_URL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-01 20:39:02 +00:00
parent def94bfeb8
commit bbd6cb2393
2 changed files with 10 additions and 3 deletions

View File

@@ -56,8 +56,9 @@ export async function POST(request: Request) {
);
}
// Parse broker URL from environment or use default
const brokerUrl = process.env.MQTT_BROKER_URL || 'mqtt://localhost:1883';
// Parse public broker URL from environment (for client apps like OwnTracks)
// Use MQTT_PUBLIC_BROKER_URL for external access, fallback to MQTT_BROKER_URL
const brokerUrl = process.env.MQTT_PUBLIC_BROKER_URL || process.env.MQTT_BROKER_URL || 'mqtt://localhost:1883';
const brokerHost = brokerUrl.replace(/^mqtt:\/\//, '').replace(/:\d+$/, '');
const brokerPortMatch = brokerUrl.match(/:(\d+)$/);
const brokerPort = brokerPortMatch ? brokerPortMatch[1] : '1883';