MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / handler

Function handler

packages/sdks/nextjs/createNextRouteHandler.ts:119–136  ·  view source on GitHub ↗
(req: Request)

Source from the content-addressed store, hash-verified

117 const apiUrl = options?.apiUrl ?? DEFAULT_API_URL;
118
119 const handler = async function handler(req: Request): Promise<NextResponse> {
120 const url = new URL(req.url);
121 const pathname = url.pathname;
122 const method = req.method;
123
124 // Handle script proxy: GET /op1.js
125 if (method === 'GET' && pathname.endsWith(SCRIPT_PATH)) {
126 return handleScriptProxyRoute(req);
127 }
128
129 const apiPathMatch = pathname.indexOf('/track');
130 if (apiPathMatch === -1) {
131 return NextResponse.json({ error: 'Not found' }, { status: 404 });
132 }
133
134 const apiPath = pathname.substring(apiPathMatch);
135 return handleApiRoute(req, apiUrl, apiPath);
136 };
137
138 handler.GET = handler;
139 handler.POST = handler;

Callers 4

makeServerFunction · 0.50
makeServerFunction · 0.50
makeServerFunction · 0.50
makeServerFunction · 0.50

Calls 2

handleScriptProxyRouteFunction · 0.85
handleApiRouteFunction · 0.70

Tested by 4

makeServerFunction · 0.40
makeServerFunction · 0.40
makeServerFunction · 0.40
makeServerFunction · 0.40