Unverified Commit d8cde2a5 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

fix: build CLI output not displaying Proxy (Middleware) when nodejs runtime (#85403)

parent afbdae65
......@@ -4268,6 +4268,7 @@ export default async function build(
pageExtensions: config.pageExtensions,
buildManifest,
middlewareManifest,
functionsConfigManifest,
hasGSPAndRevalidateZero,
})
)
......
......@@ -75,6 +75,7 @@ import { formatExpire, formatRevalidate } from './output/format'
import type { AppRouteRouteModule } from '../server/route-modules/app-route/module'
import { formatIssue, isRelevantWarning } from '../shared/lib/turbopack/utils'
import type { TurbopackResult } from './swc/types'
import type { FunctionsConfigManifest } from './index'
export type ROUTER_TYPE = 'pages' | 'app'
......@@ -274,6 +275,7 @@ export async function printTreeView(
pagesDir,
pageExtensions,
middlewareManifest,
functionsConfigManifest,
useStaticPages404,
hasGSPAndRevalidateZero,
}: {
......@@ -281,6 +283,7 @@ export async function printTreeView(
pageExtensions: PageExtensions
buildManifest: BuildManifest
middlewareManifest: MiddlewareManifest
functionsConfigManifest: FunctionsConfigManifest
useStaticPages404: boolean
hasGSPAndRevalidateZero: Set<string>
}
......@@ -533,8 +536,12 @@ export async function printTreeView(
list: lists.pages,
})
const middlewareInfo = middlewareManifest.middleware?.['/']
if (middlewareInfo?.files.length > 0) {
if (
middlewareManifest.middleware?.['/']?.files.length > 0 ||
// 'nodejs' runtime middleware or proxy is set to
// functions-config-manifest instead of middleware-manifest.
functionsConfigManifest.functions?.['/_middleware']
) {
messages.push([])
messages.push(['ƒ Proxy (Middleware)'])
}
......
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>hello world</p>
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig
import { nextTestSetup } from 'e2e-utils'
describe('proxy-build-cli-output', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should print proxy in the build CLI output', async () => {
expect(next.cliOutput).toContain('ƒ Proxy (Middleware)')
const browser = await next.browser('/foo')
expect(await browser.elementByCss('p').text()).toBe('hello world')
})
})
import { NextRequest, NextResponse } from 'next/server'
export default function proxy(request: NextRequest) {
if (request.nextUrl.pathname === '/foo') {
return NextResponse.redirect(new URL('/', request.url))
}
return NextResponse.next()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment