Full Toolkit for Next-Level Domain Analysis
Bypass Vercel Deployment Protection for self-referencing resolver calls ππ‘οΈ (#68)
Felix Wotschofskyda04b38b28a0
diff --git a/.env.example b/.env.exampleindex ede6653..5653a07 100644--- a/.env.example+++ b/.env.example@@ -4,6 +4,11 @@ SITE_URL=https://example.com# Secret used to authenticate internal API callsINTERNAL_API_SECRET=secret+# Vercel Deployment Protection bypass secret; required so self-referencing API calls+# can pass the firewall on protected (e.g. preview) deployments. Generated under+# Project Settings β Deployment Protection β Protection Bypass for Automation.+VERCEL_AUTOMATION_BYPASS_SECRET=+# Plausible Analytics ConfigurationNEXT_PUBLIC_PLAUSIBLE_DOMAIN=example.comNEXT_PUBLIC_PLAUSIBLE_HOST=https://customplausible.io # Optional if using plausible.iodiff --git a/lib/resolvers/internal.ts b/lib/resolvers/internal.tsindex 374ce1b..1e640fe 100644--- a/lib/resolvers/internal.ts+++ b/lib/resolvers/internal.ts@@ -27,15 +27,22 @@ export class InternalDoHResolver extends DnsResolver {}private get requestInit() {- if (!env.INTERNAL_API_SECRET) {+ const headers: Record<string, string> = {};++ if (env.INTERNAL_API_SECRET) {+ headers.Authorization = env.INTERNAL_API_SECRET;+ }++ if (env.VERCEL_AUTOMATION_BYPASS_SECRET) {+ headers['x-vercel-protection-bypass'] =+ env.VERCEL_AUTOMATION_BYPASS_SECRET;+ }++ if (Object.keys(headers).length === 0) {return {};}- return {- headers: {- Authorization: env.INTERNAL_API_SECRET,- },- };+ return { headers };}public async resolveRecordType(