add otp swagger
This commit is contained in:
@@ -1,11 +1,39 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { openApiSpec } from "@/lib/openapi";
|
import { openApiSpec } from "@/lib/openapi";
|
||||||
|
|
||||||
export async function GET() {
|
function getRequestOrigin(req: NextRequest) {
|
||||||
return NextResponse.json(openApiSpec, {
|
const forwardedProto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
||||||
|
const forwardedHost = req.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
||||||
|
const host = forwardedHost ?? req.headers.get("host");
|
||||||
|
const proto = forwardedProto ?? req.nextUrl.protocol.replace(":", "");
|
||||||
|
const origin = host ? `${proto}://${host}` : req.nextUrl.origin;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(origin);
|
||||||
|
if (url.protocol === "http:" || url.protocol === "https:") return url.origin;
|
||||||
|
} catch {
|
||||||
|
// Fall through to the same-origin server below.
|
||||||
|
}
|
||||||
|
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
return NextResponse.json({
|
||||||
|
...openApiSpec,
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: getRequestOrigin(req),
|
||||||
|
description: "Current request origin",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: "/",
|
||||||
|
description: "Same-origin fallback",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
"Cache-Control": "no-store",
|
"Cache-Control": "no-store",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ const html = `<!DOCTYPE html>
|
|||||||
docExpansion: "list",
|
docExpansion: "list",
|
||||||
defaultModelsExpandDepth: 2,
|
defaultModelsExpandDepth: 2,
|
||||||
displayRequestDuration: true,
|
displayRequestDuration: true,
|
||||||
|
requestInterceptor: function (request) {
|
||||||
|
request.credentials = "include";
|
||||||
|
return request;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -68,4 +72,3 @@ export async function GET() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ const config = {
|
|||||||
"isCustomOutput": true
|
"isCustomOutput": true
|
||||||
},
|
},
|
||||||
"relativeEnvPaths": {
|
"relativeEnvPaths": {
|
||||||
"rootEnvPath": "../../../.env",
|
"rootEnvPath": null,
|
||||||
"schemaEnvPath": "../../../.env"
|
"schemaEnvPath": "../../../.env"
|
||||||
},
|
},
|
||||||
"relativePath": "../../../prisma",
|
"relativePath": "../../../prisma",
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ const config = {
|
|||||||
"isCustomOutput": true
|
"isCustomOutput": true
|
||||||
},
|
},
|
||||||
"relativeEnvPaths": {
|
"relativeEnvPaths": {
|
||||||
"rootEnvPath": "../../../.env",
|
"rootEnvPath": null,
|
||||||
"schemaEnvPath": "../../../.env"
|
"schemaEnvPath": "../../../.env"
|
||||||
},
|
},
|
||||||
"relativePath": "../../../prisma",
|
"relativePath": "../../../prisma",
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ const config = {
|
|||||||
"isCustomOutput": true
|
"isCustomOutput": true
|
||||||
},
|
},
|
||||||
"relativeEnvPaths": {
|
"relativeEnvPaths": {
|
||||||
"rootEnvPath": "../../../.env",
|
"rootEnvPath": null,
|
||||||
"schemaEnvPath": "../../../.env"
|
"schemaEnvPath": "../../../.env"
|
||||||
},
|
},
|
||||||
"relativePath": "../../../prisma",
|
"relativePath": "../../../prisma",
|
||||||
|
|||||||
Reference in New Issue
Block a user