未验证 提交 cb290857 编写于 作者: J JJ Kasper 提交者: GitHub

Fix next start in serverless mode with public directory (#7541)

* Fix next start in serverless mode with public directory

* Add public folder to serverless test suite
上级 fa45fa0a
......@@ -13,6 +13,7 @@ import {
PAGES_MANIFEST,
PHASE_PRODUCTION_SERVER,
SERVER_DIRECTORY,
SERVERLESS_DIRECTORY,
} from '../lib/constants'
import {
getRouteMatcher,
......@@ -322,7 +323,12 @@ export default class Server {
private generatePublicRoutes(): Route[] {
const routes: Route[] = []
const publicFiles = recursiveReadDirSync(this.publicDir)
const serverBuildPath = join(this.distDir, SERVER_DIRECTORY)
const serverBuildPath = join(
this.distDir,
this.nextConfig.target === 'serverless'
? SERVERLESS_DIRECTORY
: SERVER_DIRECTORY
)
const pagesManifest = require(join(serverBuildPath, PAGES_MANIFEST))
publicFiles.forEach(path => {
......
......@@ -31,6 +31,11 @@ describe('Serverless', () => {
expect(html).toMatch(/Hello World/)
})
it('should serve file from public folder', async () => {
const content = await renderViaHTTP(appPort, '/hello.txt')
expect(content.trim()).toBe('hello world')
})
it('should render the page with dynamic import', async () => {
const html = await renderViaHTTP(appPort, '/dynamic')
expect(html).toMatch(/Hello!/)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册