Fix email links using relative paths — prepend baseUrl for absolute URLs
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m49s
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m49s
Relative linkUrl paths (e.g. /jury/competitions) were passed as-is to email templates, causing email clients to interpret them as local file protocols (x-webdoc:// on macOS). Now prepends NEXTAUTH_URL to any relative path before sending. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -426,6 +426,10 @@ async function maybeSendEmailWithSetting(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure linkUrl is absolute for emails (relative paths break in email clients)
|
||||||
|
const baseUrl = process.env.NEXTAUTH_URL || 'https://portal.monaco-opc.com'
|
||||||
|
const absoluteLinkUrl = linkUrl && linkUrl.startsWith('/') ? `${baseUrl}${linkUrl}` : linkUrl
|
||||||
|
|
||||||
await sendStyledNotificationEmail(
|
await sendStyledNotificationEmail(
|
||||||
user.email,
|
user.email,
|
||||||
user.name || 'User',
|
user.name || 'User',
|
||||||
@@ -433,7 +437,7 @@ async function maybeSendEmailWithSetting(
|
|||||||
{
|
{
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
linkUrl,
|
linkUrl: absoluteLinkUrl,
|
||||||
metadata,
|
metadata,
|
||||||
},
|
},
|
||||||
emailSetting.emailSubject || undefined
|
emailSetting.emailSubject || undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user