← Back to TIL
DE2025-01-28

E-Mail Links dynamisch aus Request-URL ableiten

#nuxt #nitro #email #cloudflare

Problem: Preview-Deployment schickt E-Mails mit Links auf Production — wo das Feature noch gar nicht existiert.

Falsch:

const loginUrl = `${process.env.BASE_URL}/login`
// → immer intellibrain.ch, auch auf Preview

Richtig:

const origin = getRequestURL(event).origin
const loginUrl = `${origin}/login`
// → feature-branch.intellibrain.pages.dev ✓

Nitro's getRequestURL(event) gibt dir die tatsächliche Request-URL. Funktioniert auf localhost, Preview und Production — ohne Environment-Variablen jonglieren.

intelliBrain

AI-augmented software development. Based in Zürich, working globally.

© 2026 intelliBrain GmbH. All rights reserved.Imprint
BUILT WITH 🧠 + AI