Skip to content

Commit 86903b1

Browse files
committed
fix: nextjs sdk to allow pass query string
1 parent 4f9d666 commit 86903b1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/sdks/nextjs/createNextRouteHandler.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,23 @@ export function createNextRouteHandler(
4444

4545
export function createScriptHandler() {
4646
return async function GET(req: Request) {
47-
if (!req.url.endsWith('op1.js')) {
47+
const url = new URL(req.url);
48+
const query = url.searchParams.toString();
49+
50+
if (!url.pathname.endsWith('op1.js')) {
4851
return NextResponse.json({ error: 'Not found' }, { status: 404 });
4952
}
5053

5154
const scriptUrl = 'https://openpanel.dev/op1.js';
5255
try {
5356
const res = await fetch(scriptUrl, {
54-
// @ts-expect-error
57+
// @ts-ignore
5558
next: { revalidate: 86400 },
5659
});
5760
const text = await res.text();
58-
const etag = `"${createHash('md5').update(text).digest('hex')}"`;
61+
const etag = `"${createHash('md5')
62+
.update(text + query)
63+
.digest('hex')}"`;
5964
return new NextResponse(text, {
6065
headers: {
6166
'Content-Type': 'text/javascript',

packages/sdks/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openpanel/nextjs",
3-
"version": "1.0.19-local",
3+
"version": "1.0.20-local",
44
"module": "index.ts",
55
"scripts": {
66
"build": "rm -rf dist && tsup",

0 commit comments

Comments
 (0)