mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(api): configure email app base URL separately
This commit is contained in:
1 parent
cb4c847d41
commit
58732f7770
8 files changed
+28
-1
No files matched your search
@@ -19,6 +19,26 @@ function trimTrailingSlash(url: string): string {
|
||||
return url.replace(/\/+$/u, '');
|
||||
}
|
||||
|
||||
function resolveEmailAppBaseUrl(master: MasterConfig): string {
|
||||
const configuredAppBaseUrl = master.integrations.email.app_base_url.trim();
|
||||
if (!configuredAppBaseUrl) return trimTrailingSlash(master.endpoints.app);
|
||||
try {
|
||||
const appBaseUrl = new URL(configuredAppBaseUrl);
|
||||
if (
|
||||
(appBaseUrl.protocol !== 'http:' && appBaseUrl.protocol !== 'https:') ||
|
||||
appBaseUrl.username ||
|
||||
appBaseUrl.password ||
|
||||
appBaseUrl.search ||
|
||||
appBaseUrl.hash
|
||||
) {
|
||||
throw new Error(`Invalid email app base URL: ${configuredAppBaseUrl}`);
|
||||
}
|
||||
return trimTrailingSlash(appBaseUrl.toString());
|
||||
} catch {
|
||||
throw new Error(`Invalid email app base URL: ${configuredAppBaseUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveGatewayInternalUrl(master: MasterConfig): string {
|
||||
const configuredInternalGateway = (
|
||||
master.internal as {
|
||||
@@ -254,6 +274,7 @@ export function buildAPIConfigFromMaster(master: MasterConfig): APIConfig {
|
||||
webhookSecret: master.integrations.email.webhook_secret ?? undefined,
|
||||
fromEmail: master.integrations.email.from_email,
|
||||
fromName: master.integrations.email.from_name,
|
||||
appBaseUrl: resolveEmailAppBaseUrl(master),
|
||||
smtp: master.integrations.email.smtp
|
||||
? {
|
||||
host: master.integrations.email.smtp.host,
|
||||
|
||||
@@ -158,6 +158,7 @@ export interface APIConfig {
|
||||
webhookSecret?: string;
|
||||
fromEmail: string;
|
||||
fromName: string;
|
||||
appBaseUrl: string;
|
||||
smtp?: {
|
||||
host: string;
|
||||
port: number;
|
||||
|
||||
@@ -160,7 +160,7 @@ function createEmailServiceForConfig(
|
||||
enabled: emailConfigSource.enabled,
|
||||
fromEmail: emailConfigSource.fromEmail,
|
||||
fromName: emailConfigSource.fromName,
|
||||
appBaseUrl: Config.endpoints.webApp,
|
||||
appBaseUrl: emailConfigSource.appBaseUrl,
|
||||
marketingBaseUrl: Config.endpoints.marketing,
|
||||
};
|
||||
return new EmailService(emailConfig, emailI18n, createEmailProvider(emailConfigSource), bouncedEmailChecker);
|
||||
|
||||
Reference in new issue
Block a user