mirror of
https://github.com/immich-app/immich.git
synced 2025-12-17 09:13:17 +03:00
fix: custom-url ssr (#20704)
This commit is contained in:
@@ -76,23 +76,36 @@ export class ApiService {
|
||||
let status = 200;
|
||||
let html = index;
|
||||
|
||||
const shareMatches = request.url.match(/^\/share\/(.+)$/);
|
||||
if (shareMatches) {
|
||||
const defaultDomain = request.host ? `${request.protocol}://${request.host}` : undefined;
|
||||
|
||||
let meta: OpenGraphTags | null = null;
|
||||
|
||||
const shareKey = request.url.match(/^\/share\/(.+)$/);
|
||||
if (shareKey) {
|
||||
try {
|
||||
const key = shareMatches[1];
|
||||
const key = shareKey[1];
|
||||
const auth = await this.authService.validateSharedLinkKey(key);
|
||||
const meta = await this.sharedLinkService.getMetadataTags(
|
||||
auth,
|
||||
request.host ? `${request.protocol}://${request.host}` : undefined,
|
||||
);
|
||||
if (meta) {
|
||||
html = render(index, meta);
|
||||
}
|
||||
meta = await this.sharedLinkService.getMetadataTags(auth, defaultDomain);
|
||||
} catch {
|
||||
status = 404;
|
||||
}
|
||||
}
|
||||
|
||||
const shareSlug = request.url.match(/^\/s\/(.+)$/);
|
||||
if (shareSlug) {
|
||||
try {
|
||||
const slug = shareSlug[1];
|
||||
const auth = await this.authService.validateSharedLinkSlug(slug);
|
||||
meta = await this.sharedLinkService.getMetadataTags(auth, defaultDomain);
|
||||
} catch {
|
||||
status = 404;
|
||||
}
|
||||
}
|
||||
|
||||
if (meta) {
|
||||
html = render(index, meta);
|
||||
}
|
||||
|
||||
res.status(status).type('text/html').header('Cache-Control', 'no-store').send(html);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user