fix(sdk): make options for createNextRouteHandler optional

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-12-03 20:33:46 +01:00
parent 2e3e7037bd
commit f48dcfe678

View File

@@ -2,12 +2,13 @@
// with esm and nextjs (when using pages dir) // with esm and nextjs (when using pages dir)
import { NextResponse } from 'next/server.js'; import { NextResponse } from 'next/server.js';
export function createNextRouteHandler({ type CreateNextRouteHandlerOptions = {
apiUrl = 'https://api.openpanel.dev',
}: {
apiUrl?: string; apiUrl?: string;
}) { };
export function createNextRouteHandler(options: CreateNextRouteHandlerOptions) {
return async function POST(req: Request) { return async function POST(req: Request) {
const apiUrl = options.apiUrl ?? 'https://api.openpanel.dev';
const headers = new Headers(req.headers); const headers = new Headers(req.headers);
try { try {
const res = await fetch(`${apiUrl}/track`, { const res = await fetch(`${apiUrl}/track`, {