Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Fix domain registration flow

Steven Tey6d5e3b3c07a2
diff --git a/apps/web/lib/api/domains/claim-dot-link-domain.ts b/apps/web/lib/api/domains/claim-dot-link-domain.ts
index f84d71fe2d..92b2f0ab67 100644
--- a/apps/web/lib/api/domains/claim-dot-link-domain.ts
+++ b/apps/web/lib/api/domains/claim-dot-link-domain.ts
@@ -58,14 +58,6 @@ export async function claimDotLinkDomain({
}),
]);
- // if for some reason the domain is already registered, we should fail
- if (response.RegisterResponse.Error) {
- throw new DubApiError({
- code: "forbidden",
- message: response.RegisterResponse.Error,
- });
- }
-
// if the domain was added to a different workspace but is not verified
// we should remove it to free up the domain for the current workspace
if (matchingUnverifiedDomain) {
diff --git a/apps/web/lib/dynadot/register-domain.ts b/apps/web/lib/dynadot/register-domain.ts
index c404839893..d7c1352ea7 100644
--- a/apps/web/lib/dynadot/register-domain.ts
+++ b/apps/web/lib/dynadot/register-domain.ts
@@ -39,9 +39,9 @@ export const registerDomain = async ({ domain }: { domain: string }) => {
const data = schema.parse(await response.json());
- if (data.RegisterResponse.Status !== "success")
+ if (data.RegisterResponse.Status !== "success" || data.RegisterResponse.Error)
throw new DubApiError({
- code: "forbidden",
+ code: "bad_request",
message: `Failed to register domain: ${data.RegisterResponse.Error}`,
});