Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow some recursion for middleware subrequests #60615

Merged
merged 9 commits into from
Feb 6, 2024
3 changes: 2 additions & 1 deletion packages/next/src/server/web/sandbox/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export const run = withTaggedErrors(async function runWithTaggedErrors(params) {
const runtime = await getRuntimeContext(params)
const subreq = params.request.headers[`x-middleware-subrequest`]
const subrequests = typeof subreq === 'string' ? subreq.split(':') : []
if (subrequests.includes(params.name)) {
const allowSubrequests = params.request.headers[`x-middleware-allow-subrequests`] === "true"
if (subrequests.includes(params.name) && !allowSubrequests) {
ijjk marked this conversation as resolved.
Show resolved Hide resolved
return {
waitUntil: Promise.resolve(),
response: new runtime.context.Response(null, {
Expand Down