mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-08 11:06:37 +08:00
22 lines
650 B
TypeScript
22 lines
650 B
TypeScript
import { NextRequest } from "next/server";
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
let apiKey = process.env.OPENAI_API_KEY;
|
|
const userApiKey = req.headers.get("token");
|
|
if (userApiKey) {
|
|
apiKey = userApiKey;
|
|
}
|
|
|
|
const res = await fetch("https://api.openai.com/dashboard/billing/credit_grants", {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${apiKey}`,
|
|
},
|
|
method: "GET"
|
|
});
|
|
console.log(res.body)
|
|
return new Response(res.body);
|
|
} catch (error) {
|
|
console.error("[TOKEN]", error);
|
|
}
|
|
} |