Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/build/functions/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const copyHandlerDependenciesForNodeMiddleware = async (ctx: PluginContext) => {

const entry = 'server/middleware.js'
const nft = `${entry}.nft.json`
const nftFilesPath = join(process.cwd(), ctx.nextDistDir, nft)
const nftFilesPath = join(process.cwd(), ctx.distDir, nft)
const nftManifest = JSON.parse(await readFile(nftFilesPath, 'utf8'))

const files: string[] = nftManifest.files.map((file: string) => join('server', file))
Expand Down
14 changes: 14 additions & 0 deletions tests/smoke/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, test } from 'vitest'
import { Fixture, fixtureFactories } from '../utils/create-e2e-fixture'
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'

const usedFixtures = new Set<Fixture>()
/**
Expand Down Expand Up @@ -37,6 +38,19 @@ async function smokeTest(createFixture: () => Promise<Fixture>) {
await expect(body).toContain('SSR: yes')
}

if (nextVersionSatisfies('>=16.0.0')) {
test('npm monorepo with proxy / node middleware', async () => {
// proxy ~= node middleware
const fixture = await selfCleaningFixtureFactories.npmMonorepoProxy()

const response = await fetch(fixture.url)
expect(response.status).toBe(200)

const body = await response.json()
expect(body).toEqual({ proxy: true })
})
}

test('yarn@3 monorepo with pnpm linker', async () => {
await smokeTest(selfCleaningFixtureFactories.yarnMonorepoWithPnpmLinker)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
}

module.exports = nextConfig
13 changes: 13 additions & 0 deletions tests/smoke/fixtures/npm-monorepo-proxy/apps/site/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@apps/site",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "next build"
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Home() {
return (
<main>
This should never render, because proxy/middleware always respond before handling pages
</main>
)
}
6 changes: 6 additions & 0 deletions tests/smoke/fixtures/npm-monorepo-proxy/apps/site/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { NextRequest } from 'next/server'
import { NextResponse } from 'next/server'

export async function proxy(request: NextRequest) {
return NextResponse.json({ proxy: true })
}
14 changes: 14 additions & 0 deletions tests/smoke/fixtures/npm-monorepo-proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "npm-monorepo-proxy",
"private": true,
"scripts": {
"build": "npm run build --workspace @apps/site"
},
"engines": {
"node": ">=18"
},
"packageManager": "[email protected]",
"workspaces": [
"apps/*"
]
}
7 changes: 7 additions & 0 deletions tests/utils/create-e2e-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ export const fixtureFactories = {
publishDirectory: 'apps/site/.next',
smoke: true,
}),
npmMonorepoProxy: () =>
createE2EFixture('npm-monorepo-proxy', {
buildCommand: 'npm run build --workspace @apps/site',
packagePath: 'apps/site',
publishDirectory: 'apps/site/.next',
smoke: true,
}),
dynamicCms: () => createE2EFixture('dynamic-cms'),
after: () => createE2EFixture('after'),
}
Loading