@aravindc26/velu 0.13.7 → 0.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { NextRequest
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
2
3
|
import { getPreviewSecret, verifyPreviewToken } from './lib/preview-auth';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Next.js middleware that enforces HMAC-signed token authentication
|
|
6
|
-
* preview page routes.
|
|
6
|
+
* Next.js proxy (middleware) that enforces HMAC-signed token authentication
|
|
7
|
+
* for preview page routes.
|
|
7
8
|
*
|
|
8
9
|
* Flow:
|
|
9
10
|
* 1. Requests with `x-preview-secret` header pass through (server-to-server API calls).
|
|
@@ -13,7 +14,7 @@ import { getPreviewSecret, verifyPreviewToken } from './lib/preview-auth';
|
|
|
13
14
|
* 4. If a valid `__velu_preview_{sessionId}` cookie exists: allow.
|
|
14
15
|
* 5. Otherwise: 403.
|
|
15
16
|
*/
|
|
16
|
-
export function
|
|
17
|
+
export function proxy(request: NextRequest) {
|
|
17
18
|
const secret = getPreviewSecret();
|
|
18
19
|
|
|
19
20
|
// No secret configured — allow everything (dev / local)
|
|
@@ -76,16 +77,8 @@ export function middleware(request: NextRequest) {
|
|
|
76
77
|
return new NextResponse('Forbidden', { status: 403 });
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
// Use Node.js runtime so we can access the crypto module for HMAC verification
|
|
80
|
-
export const runtime = 'nodejs';
|
|
81
|
-
|
|
82
80
|
export const config = {
|
|
83
81
|
matcher: [
|
|
84
|
-
/*
|
|
85
|
-
* Match all request paths except:
|
|
86
|
-
* - _next (Next.js internals)
|
|
87
|
-
* - favicon.ico, robots.txt, sitemap.xml (static meta)
|
|
88
|
-
*/
|
|
89
82
|
'/((?!_next|favicon\\.ico|robots\\.txt|sitemap\\.xml).*)',
|
|
90
83
|
],
|
|
91
84
|
};
|