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.

small middleware change

Steven Tey679f57e05829
diff --git a/lib/middleware/link.ts b/lib/middleware/link.ts
index 4cb164f4b8..bc1a73509e 100644
--- a/lib/middleware/link.ts
+++ b/lib/middleware/link.ts
@@ -29,17 +29,16 @@ export default async function LinkMiddleware(
const { url: target, password, proxy, ios, android } = response || {};
if (target) {
- if (password) {
- // rewrite to auth page (/_auth/[domain]/[key]) if the link is password protected
- console.log("password protected link", `/+auth/${domain}/${key}`);
- return NextResponse.rewrite(new URL(`/+auth/${domain}/${key}`, req.url));
- }
-
// special case for link health monitoring with planetfall.io :)
if (!req.headers.get("dub-no-track")) {
ev.waitUntil(recordClick(domain, req, key)); // track the click only if there is no `dub-no-track` header
}
+ if (password) {
+ // rewrite to auth page (/+auth/[domain]/[key]) if the link is password protected
+ return NextResponse.rewrite(new URL(`/+auth/${domain}/${key}`, req.url));
+ }
+
const isBot = detectBot(req);
if (isBot && proxy) {
// rewrite to proxy page (/_proxy/[domain]/[key]) if it's a bot
diff --git a/middleware.ts b/middleware.ts
index 713efb5c18..7c132e2b38 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -15,12 +15,12 @@ export const config = {
* Match all paths except for:
* 1. /api/ routes
* 2. /_next/ (Next.js internals)
- * 3. /_proxy/, /_auth/ (special pages for OG tags proxying and password protection)
+ * 3. /_proxy/ (special page for OG tags proxying)
* 4. /_static (inside /public)
* 5. /_vercel (Vercel internals)
* 6. /favicon.ico, /sitemap.xml (static files)
*/
- "/((?!api/|_next/|_proxy/|_auth/|_static|_vercel|favicon.ico|sitemap.xml).*)",
+ "/((?!api/|_next/|_proxy/|_static|_vercel|favicon.ico|sitemap.xml).*)",
],
};