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.

added more logs

Steven Tey8cc2eda8dbbf
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index d53e21e3c2..d23d7a4228 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -58,6 +58,7 @@ export const HOME_HOSTNAMES = new Set([
// comment for better diffs
"dub.sh",
"preview.dub.sh",
+ "localhost",
"localhost:3000",
]);
diff --git a/lib/stats.ts b/lib/stats.ts
index 7435e3c9e7..22c8f9ce75 100644
--- a/lib/stats.ts
+++ b/lib/stats.ts
@@ -132,10 +132,12 @@ export const getStats = async ({
// 3. interval is not defined
// 4. there's a connection to MySQL
if (endpoint === "clicks" && key !== "_root" && !interval && conn) {
+ console.log("Getting all-time clicks count from MySQL", domain, key);
const response = await conn.execute(
"SELECT clicks FROM Link WHERE domain = ? AND `key` = ?",
[domain, key],
);
+ console.log("MySQL response", response);
try {
const clicks = response.rows[0]["clicks"];
return clicks || "0";
diff --git a/middleware.ts b/middleware.ts
index 1324986007..d23310de77 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -7,7 +7,7 @@ import {
RootMiddleware,
} from "@/lib/middleware";
import { parse } from "@/lib/middleware/utils";
-import { isReservedKey } from "./lib/utils";
+import { isHomeHostname, isReservedKey } from "./lib/utils";
export const config = {
matcher: [
@@ -26,7 +26,7 @@ export const config = {
export default async function middleware(req: NextRequest, ev: NextFetchEvent) {
const { domain, path, key } = parse(req);
- const home = domain === "dub.sh" || domain.endsWith(".vercel.app");
+ const home = isHomeHostname(domain);
// for App (app.dub.sh and app.localhost:3000)
if (domain === "app.dub.sh" || domain === "app.localhost:3000") {