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.

update DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES

Steven Tey72a4ac2ced63
diff --git a/apps/web/app/(ee)/api/domains/register/route.ts b/apps/web/app/(ee)/api/domains/register/route.ts
index c8a8958878..c568ef03cc 100644
--- a/apps/web/app/(ee)/api/domains/register/route.ts
+++ b/apps/web/app/(ee)/api/domains/register/route.ts
@@ -2,25 +2,20 @@ import { claimDotLinkDomain } from "@/lib/api/domains/claim-dot-link-domain";
import { DubApiError } from "@/lib/api/errors";
import { parseRequestBody } from "@/lib/api/utils";
import { withWorkspace } from "@/lib/auth";
+import { DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES } from "@/lib/dynadot/constants";
import { registerDomainSchema } from "@/lib/zod/schemas/domains";
import { NextResponse } from "next/server";
-// TODO: this logic is hard-coded for now, but we'll make it dynamic in the future
-const eligibleWorkspaces = [
- "clrei1gld0002vs9mzn93p8ik",
- "ws_1JT00MX4K1KQFMT2FEF6413XT",
-];
-
// POST /api/domains/register - register a domain
export const POST = withWorkspace(
async ({ workspace, session, req }) => {
const { domain } = registerDomainSchema.parse(await parseRequestBody(req));
- if (!eligibleWorkspaces.includes(workspace.id)) {
+ if (!DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES.includes(workspace.id)) {
throw new DubApiError({
code: "forbidden",
message:
- "Your workspace is not eligible for domain registration. Contact our team for more information.",
+ "POST /domains/register is not available for your workspace. Contact support for more information.",
});
}
diff --git a/apps/web/app/(ee)/api/domains/status/route.ts b/apps/web/app/(ee)/api/domains/status/route.ts
index 715659181c..0ba3d093bd 100644
--- a/apps/web/app/(ee)/api/domains/status/route.ts
+++ b/apps/web/app/(ee)/api/domains/status/route.ts
@@ -1,5 +1,6 @@
import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
+import { DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES } from "@/lib/dynadot/constants";
import { searchDomainsAvailability } from "@/lib/dynadot/search-domains";
import {
DomainStatusSchema,
@@ -11,7 +12,7 @@ import * as z from "zod/v4";
// GET /api/domains/status - checks the availability status of one or more domains
export const GET = withWorkspace(
- async ({ searchParams }) => {
+ async ({ workspace, searchParams }) => {
let { domains } = searchDomainSchema.parse(searchParams);
if (domains.length === 0) {
@@ -22,6 +23,14 @@ export const GET = withWorkspace(
});
}
+ if (!DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES.includes(workspace.id)) {
+ throw new DubApiError({
+ code: "forbidden",
+ message:
+ "GET /domains/status is not available for your workspace. Contact support for more information.",
+ });
+ }
+
const domainsOnDub = await prisma.domain.findMany({
where: {
slug: {
diff --git a/apps/web/lib/dynadot/constants.ts b/apps/web/lib/dynadot/constants.ts
index ea28ff0471..3dd85b667a 100644
--- a/apps/web/lib/dynadot/constants.ts
+++ b/apps/web/lib/dynadot/constants.ts
@@ -2,3 +2,10 @@ export const DYNADOT_BASE_URL =
process.env.DYNADOT_BASE_URL || "https://api.dynadot.com/api3.json";
export const DYNADOT_API_KEY = process.env.DYNADOT_API_KEY || "";
export const DYNADOT_COUPON = process.env.DYNADOT_COUPON || "";
+
+// TODO: this logic is hard-coded for now, but we'll make it dynamic in the future
+export const DOMAIN_REGISTRATION_ELIGIBLE_WORKSPACES = [
+ "clrei1gld0002vs9mzn93p8ik",
+ "ws_1JT00MX4K1KQFMT2FEF6413XT",
+ "ws_1KJTC56GDYF3P9AHXSAQS5RGW",
+];