diff --git a/helpers/mail.ts b/helpers/mail.ts index 9d315c8..61943d2 100644 --- a/helpers/mail.ts +++ b/helpers/mail.ts @@ -1,3 +1,5 @@ +import { getBaseURL } from './url' + const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY const SENDGRID_URL = 'https://api.sendgrid.com/v3/mail/send' // TODO: move to env @@ -31,7 +33,7 @@ async function sendMail(data: object) { function getReceivedBookingText(booking: { uuid: string }) { return `Hallo lieber Admin, - es ging folgende Buchung ein: https://${process.env.VERCEL_URL}/booking/${booking.uuid} + es ging folgende Buchung ein: {getBaseURL()}/booking/${booking.uuid} MfG` } diff --git a/helpers/url.ts b/helpers/url.ts new file mode 100644 index 0000000..df9f9a2 --- /dev/null +++ b/helpers/url.ts @@ -0,0 +1,7 @@ +const URL = process.env.VERCEL_URL + ? `https://${process.env.VERCEL_URL}` + : 'http://localhost:3000' + +export function getBaseURL(): string { + return URL +}