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.

add rate limit headers to the error response

Kiran K4cf92e26a507
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index 73300b3404..f800788a7f 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -71,6 +71,7 @@ export const withWorkspace = (
const searchParams = getSearchParams(req.url);
let apiKey: string | undefined = undefined;
+ let headers = {};
try {
const authorizationHeader = req.headers.get("Authorization");
@@ -94,7 +95,6 @@ export const withWorkspace = (
undefined;
let session: Session | undefined;
- let headers = {};
let workspaceId: string | undefined;
let workspaceSlug: string | undefined;
@@ -160,7 +160,6 @@ export const withWorkspace = (
600,
"1 m",
).limit(apiKey);
-
headers = {
"Retry-After": reset.toString(),
"X-RateLimit-Limit": limit.toString(),
@@ -424,7 +423,7 @@ export const withWorkspace = (
link,
});
} catch (error) {
- return handleAndReturnErrorResponse(error);
+ return handleAndReturnErrorResponse(error, headers);
}
};
};
diff --git a/apps/web/tests/links/list-links.test.ts b/apps/web/tests/links/list-links.test.ts
index 24285318eb..6f3e9defe6 100644
--- a/apps/web/tests/links/list-links.test.ts
+++ b/apps/web/tests/links/list-links.test.ts
@@ -22,8 +22,6 @@ test("GET /links", async (ctx) => {
query: { workspaceId },
});
- console.log(links);
-
const linkFound = links.find((l) => l.id === firstLink.id);
expect(status).toEqual(200);