Skip to content

Full Toolkit for Next-Level Domain Analysis

Pin DNS map resolve routes with per-function regions 📍🗺️ (#127)

Felix Wotschofsky40cade94e2cd
diff --git a/app/api/internal/resolve/arn/route.ts b/app/api/internal/resolve/arn/route.ts
index 1e4b436..9e1ae16 100644
--- a/app/api/internal/resolve/arn/route.ts
+++ b/app/api/internal/resolve/arn/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'arn1';
-
+// Pinned to arn1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/bom/route.ts b/app/api/internal/resolve/bom/route.ts
index 45d64f5..4aabb93 100644
--- a/app/api/internal/resolve/bom/route.ts
+++ b/app/api/internal/resolve/bom/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'bom1';
-
+// Pinned to bom1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/cdg/route.ts b/app/api/internal/resolve/cdg/route.ts
index 7d56727..c48f381 100644
--- a/app/api/internal/resolve/cdg/route.ts
+++ b/app/api/internal/resolve/cdg/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'cdg1';
-
+// Pinned to cdg1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/cle/route.ts b/app/api/internal/resolve/cle/route.ts
index 13fc936..aa90c82 100644
--- a/app/api/internal/resolve/cle/route.ts
+++ b/app/api/internal/resolve/cle/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'cle1';
-
+// Pinned to cle1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/cpt/route.ts b/app/api/internal/resolve/cpt/route.ts
index b9709a1..0feab9f 100644
--- a/app/api/internal/resolve/cpt/route.ts
+++ b/app/api/internal/resolve/cpt/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'cpt1';
-
+// Pinned to cpt1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/dub/route.ts b/app/api/internal/resolve/dub/route.ts
index fac61e8..76080f6 100644
--- a/app/api/internal/resolve/dub/route.ts
+++ b/app/api/internal/resolve/dub/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'dub1';
-
+// Pinned to dub1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/fra/route.ts b/app/api/internal/resolve/fra/route.ts
index 47d8030..52642db 100644
--- a/app/api/internal/resolve/fra/route.ts
+++ b/app/api/internal/resolve/fra/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'fra1';
-
+// Pinned to fra1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/gru/route.ts b/app/api/internal/resolve/gru/route.ts
index fb96be5..29696a1 100644
--- a/app/api/internal/resolve/gru/route.ts
+++ b/app/api/internal/resolve/gru/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'gru1';
-
+// Pinned to gru1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/hkg/route.ts b/app/api/internal/resolve/hkg/route.ts
index ce83a2d..96b3c37 100644
--- a/app/api/internal/resolve/hkg/route.ts
+++ b/app/api/internal/resolve/hkg/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'hkg1';
-
+// Pinned to hkg1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/hnd/route.ts b/app/api/internal/resolve/hnd/route.ts
index cddf41a..307cea1 100644
--- a/app/api/internal/resolve/hnd/route.ts
+++ b/app/api/internal/resolve/hnd/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'hnd1';
-
+// Pinned to hnd1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/iad/route.ts b/app/api/internal/resolve/iad/route.ts
index faa573d..53f41c4 100644
--- a/app/api/internal/resolve/iad/route.ts
+++ b/app/api/internal/resolve/iad/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'iad1';
-
+// Pinned to iad1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/icn/route.ts b/app/api/internal/resolve/icn/route.ts
index b47b41c..e7edec1 100644
--- a/app/api/internal/resolve/icn/route.ts
+++ b/app/api/internal/resolve/icn/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'icn1';
-
+// Pinned to icn1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/kix/route.ts b/app/api/internal/resolve/kix/route.ts
index a71188b..906306e 100644
--- a/app/api/internal/resolve/kix/route.ts
+++ b/app/api/internal/resolve/kix/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'kix1';
-
+// Pinned to kix1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/lhr/route.ts b/app/api/internal/resolve/lhr/route.ts
index ef92646..87b5484 100644
--- a/app/api/internal/resolve/lhr/route.ts
+++ b/app/api/internal/resolve/lhr/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'lhr1';
-
+// Pinned to lhr1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/pdx/route.ts b/app/api/internal/resolve/pdx/route.ts
index b46b2b7..e572d96 100644
--- a/app/api/internal/resolve/pdx/route.ts
+++ b/app/api/internal/resolve/pdx/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'pdx1';
-
+// Pinned to pdx1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/regions.test.ts b/app/api/internal/resolve/regions.test.ts
new file mode 100644
index 0000000..6abc99f
--- /dev/null
+++ b/app/api/internal/resolve/regions.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from 'vitest';
+
+import { REGIONS } from '@/lib/data';
+import vercelConfig from '@/vercel.json';
+
+const functions: Record<string, { regions?: string[] }> =
+ vercelConfig.functions;
+
+describe('vercel.json', () => {
+ it.each(Object.keys(REGIONS))(
+ 'pins the %s resolve route to its Vercel region',
+ (code) => {
+ expect(
+ functions[`app/api/internal/resolve/${code}/route.ts`]?.regions,
+ ).toEqual([`${code}1`]);
+ },
+ );
+});
diff --git a/app/api/internal/resolve/sfo/route.ts b/app/api/internal/resolve/sfo/route.ts
index f54dfdf..c6aad0e 100644
--- a/app/api/internal/resolve/sfo/route.ts
+++ b/app/api/internal/resolve/sfo/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'sfo1';
-
+// Pinned to sfo1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/sin/route.ts b/app/api/internal/resolve/sin/route.ts
index 0fc0d68..ffa95ad 100644
--- a/app/api/internal/resolve/sin/route.ts
+++ b/app/api/internal/resolve/sin/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'sin1';
-
+// Pinned to sin1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/internal/resolve/syd/route.ts b/app/api/internal/resolve/syd/route.ts
index 53815b6..6b426c8 100644
--- a/app/api/internal/resolve/syd/route.ts
+++ b/app/api/internal/resolve/syd/route.ts
@@ -1,10 +1,5 @@
import { handler } from '../base';
-// Do not remove: Vercel only honours `preferredRegion` for functions on the edge
-// runtime. Without it this route falls back to the project's default region and
-// silently stops resolving DNS from the location its path name promises.
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config/preferredRegion
-export const runtime = 'edge';
-export const preferredRegion = 'syd1';
-
+// Pinned to syd1 in vercel.json. Without that entry this route runs in the
+// project's default region and stops resolving from the location it promises.
export const GET = handler;
diff --git a/app/api/search-suggestions/route.ts b/app/api/search-suggestions/route.ts
index f003389..7024e58 100644
--- a/app/api/search-suggestions/route.ts
+++ b/app/api/search-suggestions/route.ts
@@ -4,8 +4,6 @@ import { useLogger, withEvlog } from '@/lib/evlog';
import { getSearchSuggestions } from '@/lib/search';
import { normalizeDomain } from '@/lib/search-parser';
-export const preferredRegion = 'home';
-
const VALID_QUERY_REGEX = /^[a-z0-9-_.]+$/i;
export const GET = withEvlog(async (request: Request) => {
diff --git a/vercel.json b/vercel.json
new file mode 100644
index 0000000..1babbf2
--- /dev/null
+++ b/vercel.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "https://openapi.vercel.sh/vercel.json",
+ "functions": {
+ "app/api/internal/resolve/arn/route.ts": { "regions": ["arn1"] },
+ "app/api/internal/resolve/bom/route.ts": { "regions": ["bom1"] },
+ "app/api/internal/resolve/cdg/route.ts": { "regions": ["cdg1"] },
+ "app/api/internal/resolve/cle/route.ts": { "regions": ["cle1"] },
+ "app/api/internal/resolve/cpt/route.ts": { "regions": ["cpt1"] },
+ "app/api/internal/resolve/dub/route.ts": { "regions": ["dub1"] },
+ "app/api/internal/resolve/fra/route.ts": { "regions": ["fra1"] },
+ "app/api/internal/resolve/gru/route.ts": { "regions": ["gru1"] },
+ "app/api/internal/resolve/hkg/route.ts": { "regions": ["hkg1"] },
+ "app/api/internal/resolve/hnd/route.ts": { "regions": ["hnd1"] },
+ "app/api/internal/resolve/iad/route.ts": { "regions": ["iad1"] },
+ "app/api/internal/resolve/icn/route.ts": { "regions": ["icn1"] },
+ "app/api/internal/resolve/kix/route.ts": { "regions": ["kix1"] },
+ "app/api/internal/resolve/lhr/route.ts": { "regions": ["lhr1"] },
+ "app/api/internal/resolve/pdx/route.ts": { "regions": ["pdx1"] },
+ "app/api/internal/resolve/sfo/route.ts": { "regions": ["sfo1"] },
+ "app/api/internal/resolve/sin/route.ts": { "regions": ["sin1"] },
+ "app/api/internal/resolve/syd/route.ts": { "regions": ["syd1"] }
+ }
+}