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 project creation issue if no domain

Steven Teyda0ef2ff89dc
diff --git a/apps/web/app/api/projects/route.ts b/apps/web/app/api/projects/route.ts
index 74e6f311ab..e534cee703 100644
--- a/apps/web/app/api/projects/route.ts
+++ b/apps/web/app/api/projects/route.ts
@@ -112,7 +112,7 @@ export const POST = withSession(async ({ req, session }) => {
{ status: 422 },
);
}
- const response = await Promise.all([
+ const [projectResponse, domainRepsonse] = await Promise.all([
prisma.project.create({
data: {
name,
@@ -137,14 +137,18 @@ export const POST = withSession(async ({ req, session }) => {
domains: true,
},
}),
- addDomainToVercel(domain),
+ domain && addDomainToVercel(domain),
]);
- await setRootDomain({
- id: response[0].domains[0].id,
- domain,
- projectId: response[0].id,
- });
+ // if domain is specified and it was successfully added to Vercel
+ // update it in Redis cache
+ if (domain && !domainRepsonse.error) {
+ await setRootDomain({
+ id: projectResponse.domains[0].id,
+ domain,
+ projectId: projectResponse.id,
+ });
+ }
- return NextResponse.json(response);
+ return NextResponse.json(projectResponse);
});