Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4263,6 +4263,7 @@ export default async function build(
pageExtensions: config.pageExtensions,
buildManifest,
middlewareManifest,
functionsConfigManifest,
hasGSPAndRevalidateZero,
})
)
Expand Down
11 changes: 9 additions & 2 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -274,13 +275,15 @@ export async function printTreeView(
pagesDir,
pageExtensions,
middlewareManifest,
functionsConfigManifest,
useStaticPages404,
hasGSPAndRevalidateZero,
}: {
pagesDir?: string
pageExtensions: PageExtensions
buildManifest: BuildManifest
middlewareManifest: MiddlewareManifest
functionsConfigManifest: FunctionsConfigManifest
useStaticPages404: boolean
hasGSPAndRevalidateZero: Set<string>
}
Expand Down Expand Up @@ -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)'])
}
Expand Down
8 changes: 8 additions & 0 deletions test/production/app-dir/proxy-build-cli-output/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
3 changes: 3 additions & 0 deletions test/production/app-dir/proxy-build-cli-output/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
6 changes: 6 additions & 0 deletions test/production/app-dir/proxy-build-cli-output/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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')
})
})
8 changes: 8 additions & 0 deletions test/production/app-dir/proxy-build-cli-output/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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()
}
Loading