Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: remove redirect if it fails

Marc Seitz1bd437dae009
diff --git a/pages/api/teams/[teamId]/domains/index.ts b/pages/api/teams/[teamId]/domains/index.ts
index 14924cab..d3a8c2fb 100644
--- a/pages/api/teams/[teamId]/domains/index.ts
+++ b/pages/api/teams/[teamId]/domains/index.ts
@@ -135,7 +135,16 @@ export default async function handle(
await addDomainToVercel(sanitizedDomain);
if (validatedRedirectUrl) {
- await setDomainRedirectUrl(sanitizedDomain, validatedRedirectUrl);
+ try {
+ await setDomainRedirectUrl(sanitizedDomain, validatedRedirectUrl);
+ } catch {
+ // Domain is functional but redirect failed to persist in Redis.
+ // Remove redirectUrl from DB so the two stores stay consistent.
+ await prisma.domain.update({
+ where: { id: response.id },
+ data: { redirectUrl: null },
+ });
+ }
}
return res.status(201).json(response);