fix: allow Next.js RSC/Server Action requests through proxy
Simplified API route matching and added RSC/next-action header passthrough to prevent 'Failed to find Server Action' errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+13
-16
@@ -12,30 +12,27 @@ async function sha256(input: string): Promise<string> {
|
|||||||
export default async function proxy(request: NextRequest) {
|
export default async function proxy(request: NextRequest) {
|
||||||
const { pathname } = request.nextUrl
|
const { pathname } = request.nextUrl
|
||||||
|
|
||||||
// Allow: /zugang page, site-auth API, static assets, favicon
|
// Allow: /zugang page, site-auth API, static assets, favicon, Next.js internals
|
||||||
if (
|
if (
|
||||||
pathname === '/zugang' ||
|
pathname === '/zugang' ||
|
||||||
pathname.startsWith('/api/site-auth') ||
|
pathname.startsWith('/api/site-auth') ||
|
||||||
pathname.startsWith('/_next') ||
|
pathname.startsWith('/_next') ||
|
||||||
pathname === '/favicon.ico' ||
|
pathname === '/favicon.ico' ||
|
||||||
pathname === '/icon.svg'
|
pathname === '/icon.svg' ||
|
||||||
|
pathname.startsWith('/icon')
|
||||||
) {
|
) {
|
||||||
return NextResponse.next()
|
return NextResponse.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public API routes (no auth required)
|
// Allow all API routes and Next.js internal action requests
|
||||||
if (
|
if (pathname.startsWith('/api/')) {
|
||||||
pathname.startsWith('/api/contributions') ||
|
return NextResponse.next()
|
||||||
pathname.startsWith('/api/upload') ||
|
}
|
||||||
pathname.startsWith('/api/candles') ||
|
|
||||||
pathname.startsWith('/api/family-upload') ||
|
// Allow Next.js RSC/Server Action requests (internal framework requests)
|
||||||
pathname.startsWith('/api/timeline') ||
|
const nextAction = request.headers.get('next-action')
|
||||||
pathname.startsWith('/api/recipes') ||
|
const rsc = request.headers.get('rsc')
|
||||||
pathname.startsWith('/api/memories') ||
|
if (nextAction || rsc) {
|
||||||
pathname.startsWith('/api/media') ||
|
|
||||||
pathname.startsWith('/api/files') ||
|
|
||||||
pathname.startsWith('/api/auth')
|
|
||||||
) {
|
|
||||||
return NextResponse.next()
|
return NextResponse.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user