fix: custom-url ssr (#20704)

This commit is contained in:
Jason Rasmussen
2025-08-05 17:29:01 -04:00
committed by GitHub
parent d430b869ac
commit a5760129f0
2 changed files with 36 additions and 11 deletions

View File

@@ -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);
};
}