The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
set security requirement to optional for all paths
Kiran K8a983cb96da0
diff --git a/apps/web/app/api/route.ts b/apps/web/app/api/route.tsindex 168f2b8a00..9aeac98b30 100644--- a/apps/web/app/api/route.ts+++ b/apps/web/app/api/route.ts@@ -5,5 +5,39 @@ import { createDocument } from "zod-openapi";export const runtime = "edge";export function GET() {- return NextResponse.json(createDocument(openApiObject));+ const document = createDocument(openApiObject);++ if (!document || !document.paths) {+ throw new Error("Failed to create OpenAPI spec.");+ }++ // Set security requirement to optional for all paths+ // This is for Speakeasy auth hook to work+ const paths = Object.keys(document.paths);++ for (const path of paths) {+ const pathItem = document.paths[path];++ if (pathItem.get) {+ pathItem?.get?.security?.push({});+ }++ if (pathItem.post) {+ pathItem?.post?.security?.push({});+ }++ if (pathItem.put) {+ pathItem?.put?.security?.push({});+ }++ if (pathItem.delete) {+ pathItem?.delete?.security?.push({});+ }++ if (pathItem.patch) {+ pathItem?.patch?.security?.push({});+ }+ }++ return NextResponse.json(document);}