diff --git a/backend/src/utils/url.utils.ts b/backend/src/utils/url.utils.ts index d1dcf4d..d1434c2 100644 --- a/backend/src/utils/url.utils.ts +++ b/backend/src/utils/url.utils.ts @@ -6,14 +6,26 @@ import { HttpContextService } from '../services/http-context.service.js'; * Returns the base URL for the application. * * If the global `MEET_BASE_URL` variable is defined, it returns its value, - * ensuring there is no trailing slash. Otherwise, it retrieves the base URL - * from the `HttpContextService` instance. + * ensuring there is no trailing slash and removing default ports (443 for HTTPS, 80 for HTTP). + * Otherwise, it retrieves the base URL from the `HttpContextService` instance. * * @returns {string} The base URL as a string. */ export const getBaseUrl = (): string => { if (MEET_BASE_URL) { - return MEET_BASE_URL.endsWith('/') ? MEET_BASE_URL.slice(0, -1) : MEET_BASE_URL; + let baseUrl = MEET_BASE_URL.endsWith('/') ? MEET_BASE_URL.slice(0, -1) : MEET_BASE_URL; + + // Remove default port 443 for HTTPS URLs + if (baseUrl.startsWith('https://') && baseUrl.includes(':443')) { + baseUrl = baseUrl.replace(':443', ''); + } + + // Remove default port 80 for HTTP URLs + if (baseUrl.startsWith('http://') && baseUrl.includes(':80')) { + baseUrl = baseUrl.replace(':80', ''); + } + + return baseUrl; } const httpContextService = container.get(HttpContextService);