mirror of
https://github.com/luxfhe/example-smart-wallet.git
synced 2026-10-30 18:13:16 +00:00
35 lines
867 B
TypeScript
35 lines
867 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getAlchemySepoliaUrl } from "~~/utils/scaffold-eth";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const body = await req.text();
|
|
const headers: Record<string, string> = {};
|
|
req.headers.forEach((value: string, key: string) => {
|
|
// don't pass the cookie because it doesn't get used downstream
|
|
if (key === "cookie") return;
|
|
|
|
headers[key] = value;
|
|
});
|
|
|
|
console.log("abi/rpc", req);
|
|
|
|
const res = await fetch(getAlchemySepoliaUrl(), {
|
|
method: "POST",
|
|
headers: {
|
|
...headers,
|
|
},
|
|
body,
|
|
});
|
|
|
|
console.log("api/rpc", res);
|
|
|
|
if (!res.ok) {
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
return NextResponse.json(await res.json().catch(e => ({})), {
|
|
status: res.status,
|
|
});
|
|
}
|
|
|
|
return NextResponse.json(await res.json());
|
|
}
|