fix: nextjs sdk to allow pass query string

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-25 10:36:57 +01:00
parent 4f9d66693e
commit 86903b1937
2 changed files with 9 additions and 4 deletions

View File

@@ -44,18 +44,23 @@ export function createNextRouteHandler(
export function createScriptHandler() {
return async function GET(req: Request) {
if (!req.url.endsWith('op1.js')) {
const url = new URL(req.url);
const query = url.searchParams.toString();
if (!url.pathname.endsWith('op1.js')) {
return NextResponse.json({ error: 'Not found' }, { status: 404 });
}
const scriptUrl = 'https://openpanel.dev/op1.js';
try {
const res = await fetch(scriptUrl, {
// @ts-expect-error
// @ts-ignore
next: { revalidate: 86400 },
});
const text = await res.text();
const etag = `"${createHash('md5').update(text).digest('hex')}"`;
const etag = `"${createHash('md5')
.update(text + query)
.digest('hex')}"`;
return new NextResponse(text, {
headers: {
'Content-Type': 'text/javascript',

View File

@@ -1,6 +1,6 @@
{
"name": "@openpanel/nextjs",
"version": "1.0.19-local",
"version": "1.0.20-local",
"module": "index.ts",
"scripts": {
"build": "rm -rf dist && tsup",