Skip to content

High performance self-hosted photo and video management solution.

feat: use my.immich.app for externalDomain fallback (#17209)

bo0tzze4f83680d9ad
diff --git a/e2e/src/api/specs/shared-link.e2e-spec.ts b/e2e/src/api/specs/shared-link.e2e-spec.ts
index 154f190f53..afad771bfc 100644
--- a/e2e/src/api/specs/shared-link.e2e-spec.ts
+++ b/e2e/src/api/specs/shared-link.e2e-spec.ts
@@ -117,7 +117,7 @@ describe('/shared-links', () => {
const resp = await request(shareUrl).get(`/${linkWithAssets.key}`);
expect(resp.status).toBe(200);
expect(resp.header['content-type']).toContain('text/html');
- expect(resp.text).toContain(`<meta property="og:image" content="http://`);
+ expect(resp.text).toContain(`<meta property="og:image" content="https://my.immich.app`);
});
});
diff --git a/server/src/services/notification.service.spec.ts b/server/src/services/notification.service.spec.ts
index 0deb3805e5..89f211b297 100644
--- a/server/src/services/notification.service.spec.ts
+++ b/server/src/services/notification.service.spec.ts
@@ -265,7 +265,7 @@ describe(NotificationService.name, () => {
await expect(sut.sendTestEmail('', configs.smtpTransport.notifications.smtp)).resolves.not.toThrow();
expect(mocks.notification.renderEmail).toHaveBeenCalledWith({
template: EmailTemplate.TEST_EMAIL,
- data: { baseUrl: 'http://localhost:2283', displayName: userStub.admin.name },
+ data: { baseUrl: 'https://my.immich.app', displayName: userStub.admin.name },
});
expect(mocks.notification.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
@@ -306,7 +306,7 @@ describe(NotificationService.name, () => {
).resolves.not.toThrow();
expect(mocks.notification.renderEmail).toHaveBeenCalledWith({
template: EmailTemplate.TEST_EMAIL,
- data: { baseUrl: 'http://localhost:2283', displayName: userStub.admin.name },
+ data: { baseUrl: 'https://my.immich.app', displayName: userStub.admin.name },
});
expect(mocks.notification.sendEmail).toHaveBeenCalledWith(
expect.objectContaining({
diff --git a/server/src/services/notification.service.ts b/server/src/services/notification.service.ts
index bc6f6b8c2f..0b8b332960 100644
--- a/server/src/services/notification.service.ts
+++ b/server/src/services/notification.service.ts
@@ -146,11 +146,10 @@ export class NotificationService extends BaseService {
}
const { server } = await this.getConfig({ withCache: false });
- const { port } = this.configRepository.getEnv();
const { html, text } = await this.notificationRepository.renderEmail({
template: EmailTemplate.TEST_EMAIL,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
displayName: user.name,
},
customTemplate: tempTemplate!,
@@ -170,7 +169,6 @@ export class NotificationService extends BaseService {
async getTemplate(name: EmailTemplate, customTemplate: string) {
const { server, templates } = await this.getConfig({ withCache: false });
- const { port } = this.configRepository.getEnv();
let templateResponse = '';
@@ -179,7 +177,7 @@ export class NotificationService extends BaseService {
const { html: _welcomeHtml } = await this.notificationRepository.renderEmail({
template: EmailTemplate.WELCOME,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
displayName: 'John Doe',
username: '[email protected]',
password: 'thisIsAPassword123',
@@ -194,7 +192,7 @@ export class NotificationService extends BaseService {
const { html: _updateAlbumHtml } = await this.notificationRepository.renderEmail({
template: EmailTemplate.ALBUM_UPDATE,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
albumId: '1',
albumName: 'Favorite Photos',
recipientName: 'Jane Doe',
@@ -210,7 +208,7 @@ export class NotificationService extends BaseService {
const { html } = await this.notificationRepository.renderEmail({
template: EmailTemplate.ALBUM_INVITE,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
albumId: '1',
albumName: "John Doe's Favorites",
senderName: 'John Doe',
@@ -239,11 +237,10 @@ export class NotificationService extends BaseService {
}
const { server, templates } = await this.getConfig({ withCache: true });
- const { port } = this.configRepository.getEnv();
const { html, text } = await this.notificationRepository.renderEmail({
template: EmailTemplate.WELCOME,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
displayName: user.name,
username: user.email,
password: tempPassword,
@@ -285,11 +282,10 @@ export class NotificationService extends BaseService {
const attachment = await this.getAlbumThumbnailAttachment(album);
const { server, templates } = await this.getConfig({ withCache: false });
- const { port } = this.configRepository.getEnv();
const { html, text } = await this.notificationRepository.renderEmail({
template: EmailTemplate.ALBUM_INVITE,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
albumId: album.id,
albumName: album.albumName,
senderName: album.owner.name,
@@ -332,7 +328,6 @@ export class NotificationService extends BaseService {
const attachment = await this.getAlbumThumbnailAttachment(album);
const { server, templates } = await this.getConfig({ withCache: false });
- const { port } = this.configRepository.getEnv();
for (const recipient of recipients) {
const user = await this.userRepository.get(recipient.id, { withDeleted: false });
@@ -349,7 +344,7 @@ export class NotificationService extends BaseService {
const { html, text } = await this.notificationRepository.renderEmail({
template: EmailTemplate.ALBUM_UPDATE,
data: {
- baseUrl: getExternalDomain(server, port),
+ baseUrl: getExternalDomain(server),
albumId: album.id,
albumName: album.albumName,
recipientName: recipient.name,
diff --git a/server/src/services/shared-link.service.spec.ts b/server/src/services/shared-link.service.spec.ts
index 557fdd5780..8c79f752b7 100644
--- a/server/src/services/shared-link.service.spec.ts
+++ b/server/src/services/shared-link.service.spec.ts
@@ -309,7 +309,7 @@ describe(SharedLinkService.name, () => {
mocks.sharedLink.get.mockResolvedValue(sharedLinkStub.individual);
await expect(sut.getMetadataTags(authStub.adminSharedLink)).resolves.toEqual({
description: '1 shared photos & videos',
- imageUrl: `http://localhost:2283/api/assets/asset-id/thumbnail?key=LCtkaJX4R1O_9D-2lq0STzsPryoL1UdAbyb6Sna1xxmQCSuqU2J1ZUsqt6GR-yGm1s0`,
+ imageUrl: `https://my.immich.app/api/assets/asset-id/thumbnail?key=LCtkaJX4R1O_9D-2lq0STzsPryoL1UdAbyb6Sna1xxmQCSuqU2J1ZUsqt6GR-yGm1s0`,
title: 'Public Share',
});
expect(mocks.sharedLink.get).toHaveBeenCalled();
@@ -319,7 +319,7 @@ describe(SharedLinkService.name, () => {
mocks.sharedLink.get.mockResolvedValue({ ...sharedLinkStub.individual, album: undefined, assets: [] });
await expect(sut.getMetadataTags(authStub.adminSharedLink)).resolves.toEqual({
description: '0 shared photos & videos',
- imageUrl: `http://localhost:2283/feature-panel.png`,
+ imageUrl: `https://my.immich.app/feature-panel.png`,
title: 'Public Share',
});
expect(mocks.sharedLink.get).toHaveBeenCalled();
diff --git a/server/src/services/shared-link.service.ts b/server/src/services/shared-link.service.ts
index 74595bb9a2..95f8cef5f8 100644
--- a/server/src/services/shared-link.service.ts
+++ b/server/src/services/shared-link.service.ts
@@ -180,7 +180,6 @@ export class SharedLinkService extends BaseService {
}
const config = await this.getConfig({ withCache: true });
- const { port } = this.configRepository.getEnv();
const sharedLink = await this.findOrFail(auth.sharedLink.userId, auth.sharedLink.id);
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;
const assetCount = sharedLink.assets.length > 0 ? sharedLink.assets.length : sharedLink.album?.assets.length || 0;
@@ -191,7 +190,7 @@ export class SharedLinkService extends BaseService {
return {
title: sharedLink.album ? sharedLink.album.albumName : 'Public Share',
description: sharedLink.description || `${assetCount} shared photos & videos`,
- imageUrl: new URL(imagePath, getExternalDomain(config.server, port)).href,
+ imageUrl: new URL(imagePath, getExternalDomain(config.server)).href,
};
}
diff --git a/server/src/utils/misc.ts b/server/src/utils/misc.ts
index b0c4fd955f..ff1656da74 100644
--- a/server/src/utils/misc.ts
+++ b/server/src/utils/misc.ts
@@ -44,8 +44,7 @@ export const getMethodNames = (instance: any) => {
return methods;
};
-export const getExternalDomain = (server: SystemConfig['server'], port: number) =>
- server.externalDomain || `http://localhost:${port}`;
+export const getExternalDomain = (server: SystemConfig['server']) => server.externalDomain || `https://my.immich.app`;
/**
* @returns a list of strings representing the keys of the object in dot notation