The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix tags security
Steven Teybe012aa4f068
diff --git a/apps/web/app/api/tags/[id]/route.ts b/apps/web/app/api/tags/[id]/route.tsindex 640e29a077..68689002da 100644--- a/apps/web/app/api/tags/[id]/route.ts+++ b/apps/web/app/api/tags/[id]/route.ts@@ -6,13 +6,14 @@ import { updateTagBodySchema } from "@/lib/zod/schemas/tags";import { NextResponse } from "next/server";// PUT /api/workspaces/[idOrSlug]/tags/[id] – update a tag for a workspace-export const PUT = withAuth(async ({ req, params }) => {+export const PUT = withAuth(async ({ req, params, workspace }) => {const { id } = params;const { name, color } = updateTagBodySchema.parse(await req.json());- const tag = await prisma.tag.findUnique({+ const tag = await prisma.tag.findFirst({where: {id,+ projectId: workspace.id,},});@@ -47,18 +48,26 @@ export const PUT = withAuth(async ({ req, params }) => {});// DELETE /api/workspaces/[idOrSlug]/tags/[id] – delete a tag for a workspace-export const DELETE = withAuth(async ({ params }) => {+export const DELETE = withAuth(async ({ params, workspace }) => {const { id } = params;try {const response = await prisma.tag.delete({where: {id,+ projectId: workspace.id,},include: {linksNew: true,},});+ if (!response) {+ throw new DubApiError({+ code: "not_found",+ message: "Tag not found.",+ });+ }+// update links metadata in tinybird after deleting a tagawait Promise.all(response.linksNew.map(async ({ linkId }) => {