Commit b9865ba3 authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Add checking filesystem after each rewrite (#9568)

* Add check: true behavior to custom routes

* Update adding dev routes

* Add checking of pages and dynamic routes for check: true

* Fix hasPage binding

* Add tests for check: true behavior

* Update regex checking

* Make changes based on review

* Update to handle rewrites in serverless loader

* Update to not change req.url

* Make sure to always parse dynamic route params

* Export all of pathToRegexp from path-match
Co-authored-by: 's avatarJoe Haddad <timer150@gmail.com>
parent 5c3f9ba7
......@@ -184,6 +184,8 @@ export default async function build(dir: string, conf = null): Promise<void> {
const mappedPages = createPagesMapping(pagePaths, config.pageExtensions)
const entrypoints = createEntrypoints(mappedPages, target, buildId, config)
const pageKeys = Object.keys(mappedPages)
const dynamicRoutes = pageKeys.filter(page => isDynamicRoute(page))
const conflictingPublicFiles: string[] = []
if (hasPublicDir) {
......@@ -216,6 +218,47 @@ export default async function build(dir: string, conf = null): Promise<void> {
)
}
const buildCustomRoute = (
r: {
source: string
statusCode?: number
},
isRedirect = false
) => {
const keys: any[] = []
const routeRegex = pathToRegexp(r.source, keys, {
strict: true,
sensitive: false,
delimiter: '/', // default is `/#?`, but Next does not pass query info
})
return {
...r,
...(isRedirect
? {
statusCode: r.statusCode || DEFAULT_REDIRECT_STATUS,
}
: {}),
regex: routeRegex.source,
regexKeys: keys.map(k => k.name),
}
}
await mkdirp(distDir)
await fsWriteFile(
path.join(distDir, ROUTES_MANIFEST),
JSON.stringify({
version: 1,
redirects: redirects.map(r => buildCustomRoute(r, true)),
rewrites: rewrites.map(r => buildCustomRoute(r)),
dynamicRoutes: getSortedRoutes(dynamicRoutes).map(page => ({
page,
regex: getRouteRegex(page).re.source,
})),
}),
'utf8'
)
const configs = await Promise.all([
getBaseWebpackConfig(dir, {
tracer,
......@@ -335,7 +378,6 @@ export default async function build(dir: string, conf = null): Promise<void> {
prefixText: 'Automatically optimizing pages',
})
const pageKeys = Object.keys(mappedPages)
const manifestPath = path.join(
distDir,
isLikeServerless ? SERVERLESS_DIRECTORY : SERVER_DIRECTORY,
......@@ -492,7 +534,6 @@ export default async function build(dir: string, conf = null): Promise<void> {
await writeBuildId(distDir, buildId)
const dynamicRoutes = pageKeys.filter(page => isDynamicRoute(page))
if (config.experimental.catchAllRouting !== true) {
if (dynamicRoutes.some(page => /\/\[\.{3}[^/]+?\](?=\/|$)/.test(page))) {
throw new Error(
......@@ -638,46 +679,6 @@ export default async function build(dir: string, conf = null): Promise<void> {
await fsWriteFile(manifestPath, JSON.stringify(pagesManifest), 'utf8')
}
const buildCustomRoute = (
r: {
source: string
statusCode?: number
},
isRedirect = false
) => {
const keys: any[] = []
const routeRegex = pathToRegexp(r.source, keys, {
strict: true,
sensitive: false,
delimiter: '/', // default is `/#?`, but Next does not pass query info
})
return {
...r,
...(isRedirect
? {
statusCode: r.statusCode || DEFAULT_REDIRECT_STATUS,
}
: {}),
regex: routeRegex.source,
regexKeys: keys.map(k => k.name),
}
}
await fsWriteFile(
path.join(distDir, ROUTES_MANIFEST),
JSON.stringify({
version: 1,
redirects: redirects.map(r => buildCustomRoute(r, true)),
rewrites: rewrites.map(r => buildCustomRoute(r)),
dynamicRoutes: getSortedRoutes(dynamicRoutes).map(page => ({
page,
regex: getRouteRegex(page).re.source,
})),
}),
'utf8'
)
if (postBuildSpinner) postBuildSpinner.stopAndPersist()
console.log()
......
......@@ -3,6 +3,7 @@ import { join } from 'path'
import { parse } from 'querystring'
import {
BUILD_MANIFEST,
ROUTES_MANIFEST,
REACT_LOADABLE_MANIFEST,
} from '../../../next-server/lib/constants'
import { isDynamicRoute } from '../../../next-server/lib/router/utils'
......@@ -42,33 +43,107 @@ const nextServerlessLoader: loader.Loader = function() {
/\\/g,
'/'
)
const routesManifest = join(distDir, ROUTES_MANIFEST).replace(/\\/g, '/')
const escapedBuildId = buildId.replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&')
const pageIsDynamicRoute = isDynamicRoute(page)
if (page.match(API_ROUTE)) {
return `
${
isDynamicRoute(page)
? `
import { getRouteMatcher } from 'next/dist/next-server/lib/router/utils/route-matcher';
const dynamicRouteImports = pageIsDynamicRoute
? `
import { getRouteMatcher } from 'next/dist/next-server/lib/router/utils/route-matcher';
import { getRouteRegex } from 'next/dist/next-server/lib/router/utils/route-regex';
`
: ``
`
: ''
const dynamicRouteMatcher = pageIsDynamicRoute
? `
const dynamicRouteMatcher = getRouteMatcher(getRouteRegex("${page}"))
`
: ''
const rewriteImports = `
import { rewrites } from '${routesManifest}'
import pathMatch, { pathToRegexp } from 'next/dist/next-server/server/lib/path-match'
`
const handleRewrites = `
const getCustomRouteMatcher = pathMatch(true)
function handleRewrites(parsedUrl) {
for (const rewrite of rewrites) {
const matcher = getCustomRouteMatcher(rewrite.source)
const params = matcher(parsedUrl.pathname)
if (params) {
parsedUrl.query = {
...parsedUrl.query,
...params
}
const parsedDest = parse(rewrite.destination)
const destCompiler = pathToRegexp.compile(
\`\${parsedDest.pathname}\${parsedDest.hash || ''}\`
)
const newUrl = destCompiler(params)
const parsedNewUrl = parse(newUrl)
parsedUrl.pathname = parsedNewUrl.pathname
parsedUrl.hash = parsedNewUrl.hash
if (parsedUrl.pathname === '${page}'){
break
}
${
pageIsDynamicRoute
? `
const dynamicParams = dynamicRouteMatcher(parsedUrl.pathname);\
if (dynamicParams) {
parsedUrl.query = {
...parsedUrl.query,
...dynamicParams
}
break
}
`
: ''
}
}
}
return parsedUrl
}
`
if (page.match(API_ROUTE)) {
return `
${dynamicRouteImports}
import { parse } from 'url'
import { apiResolver } from 'next/dist/next-server/server/api-utils'
import initServer from 'next-plugin-loader?middleware=on-init-server!'
import onError from 'next-plugin-loader?middleware=on-error-server!'
${rewriteImports}
${dynamicRouteMatcher}
${handleRewrites}
export default async (req, res) => {
try {
await initServer()
const parsedUrl = parse(req.url, true)
const params = ${
isDynamicRoute(page)
? `getRouteMatcher(getRouteRegex('${page}'))(parse(req.url).pathname)`
pageIsDynamicRoute
? `dynamicRouteMatcher(parsedUrl.pathname)`
: `{}`
}
const resolver = require('${absolutePagePath}')
apiResolver(req, res, params, resolver, onError)
apiResolver(
req,
res,
Object.assign({}, parsedUrl.query, params ),
resolver,
onError
)
} catch (err) {
console.error(err)
await onError(err)
......@@ -85,23 +160,24 @@ const nextServerlessLoader: loader.Loader = function() {
import {sendHTML} from 'next/dist/next-server/server/send-html';
import initServer from 'next-plugin-loader?middleware=on-init-server!'
import onError from 'next-plugin-loader?middleware=on-error-server!'
${
isDynamicRoute(page)
? `import {getRouteMatcher, getRouteRegex} from 'next/dist/next-server/lib/router/utils';`
: ''
}
import buildManifest from '${buildManifest}';
import reactLoadableManifest from '${reactLoadableManifest}';
import Document from '${absoluteDocumentPath}';
import Error from '${absoluteErrorPath}';
import App from '${absoluteAppPath}';
import * as ComponentInfo from '${absolutePagePath}';
${dynamicRouteImports}
${rewriteImports}
const Component = ComponentInfo.default
export default Component
export const unstable_getStaticProps = ComponentInfo['unstable_getStaticProp' + 's']
export const unstable_getStaticParams = ComponentInfo['unstable_getStaticParam' + 's']
export const unstable_getStaticPaths = ComponentInfo['unstable_getStaticPath' + 's']
${dynamicRouteMatcher}
${handleRewrites}
export const config = ComponentInfo['confi' + 'g'] || {}
export const _app = App
export async function renderReqToHTML(req, res, fromExport, _renderOpts, _params) {
......@@ -127,7 +203,8 @@ const nextServerlessLoader: loader.Loader = function() {
.replace(new RegExp('/_next/data/${escapedBuildId}/'), '/')
.replace(/\\.json$/, '')
}
const parsedUrl = parse(req.url, true)
const parsedUrl = handleRewrites(parse(req.url, true))
const renderOpts = Object.assign(
{
Component,
......@@ -140,8 +217,8 @@ const nextServerlessLoader: loader.Loader = function() {
try {
${page === '/_error' ? `res.statusCode = 404` : ''}
${
isDynamicRoute(page)
? `const params = fromExport && !unstable_getStaticProps ? {} : getRouteMatcher(getRouteRegex("${page}"))(parsedUrl.pathname) || {};`
pageIsDynamicRoute
? `const params = fromExport && !unstable_getStaticProps ? {} : dynamicRouteMatcher(parsedUrl.pathname) || {};`
: `const params = {};`
}
${
......@@ -150,7 +227,7 @@ const nextServerlessLoader: loader.Loader = function() {
// into our builder to ensure we're decoupled. However, this entails
// removing reliance on `req.url` and using `req.query` instead
// (which is needed for "custom routes" anyway).
isDynamicRoute(page)
pageIsDynamicRoute
? `const nowParams = req.headers && req.headers["x-now-route-matches"]
? getRouteMatcher(
(function() {
......
import { match } from 'path-to-regexp'
import * as pathToRegexp from 'path-to-regexp'
export { pathToRegexp }
export default (customRoute = false) => {
return (path: string) => {
const matcher = match(path, {
const matcher = pathToRegexp.match(path, {
sensitive: false,
delimiter: '/',
...(customRoute ? { strict: true } : undefined),
......
......@@ -34,7 +34,13 @@ import { recursiveReadDirSync } from './lib/recursive-readdir-sync'
import { loadComponents, LoadComponentsReturnType } from './load-components'
import { renderToHTML } from './render'
import { getPagePath } from './require'
import Router, { Params, route, Route, RouteMatch } from './router'
import Router, {
Params,
route,
Route,
DynamicRoutes,
PageChecker,
} from './router'
import { sendHTML } from './send-html'
import { serveStatic } from './serve-static'
import { getSprCache, initializeSprCache, setSprCache } from './spr-cache'
......@@ -95,7 +101,7 @@ export default class Server {
private compression?: Middleware
private onErrorMiddleware?: ({ err }: { err: Error }) => Promise<void>
router: Router
protected dynamicRoutes?: Array<{ page: string; match: RouteMatch }>
protected dynamicRoutes?: DynamicRoutes
protected customRoutes?: {
rewrites: Rewrite[]
redirects: Redirect[]
......@@ -256,7 +262,13 @@ export default class Server {
return require(join(this.distDir, ROUTES_MANIFEST))
}
protected generateRoutes(): Route[] {
protected generateRoutes(): {
routes: Route[]
fsRoutes: Route[]
catchAllRoute: Route
pageChecker: PageChecker
dynamicRoutes: DynamicRoutes | undefined
} {
this.customRoutes = this.getCustomRoutes()
const publicRoutes = fs.existsSync(this.publicDir)
......@@ -283,7 +295,7 @@ export default class Server {
]
: []
const topRoutes: Route[] = [
const fsRoutes: Route[] = [
{
match: route('/_next/static/:path*'),
type: 'route',
......@@ -377,7 +389,7 @@ export default class Server {
...publicRoutes,
...staticFilesRoute,
]
const routes: Route[] = [...topRoutes]
const routes: Route[] = []
if (this.customRoutes) {
const { redirects, rewrites } = this.customRoutes
......@@ -399,6 +411,7 @@ export default class Server {
routes.push(
...customRoutes.map(route => {
return {
check: true,
match: route.matcher,
type: route.type,
statusCode: route.statusCode,
......@@ -450,27 +463,42 @@ export default class Server {
} as Route
})
)
// make sure previous routes can still be rewritten to by
// custom routes e.g. /docs/_next/static -> /_next/static
routes.push(...topRoutes)
}
routes.push({
match: route('/api/:path*'),
const catchAllRoute: Route = {
match: route('/:path*'),
type: 'route',
name: 'API Route',
name: 'Catchall render',
fn: async (req, res, params, parsedUrl) => {
const { pathname } = parsedUrl
await this.handleApiRequest(
req as NextApiRequest,
res as NextApiResponse,
pathname!
)
const { pathname, query } = parsedUrl
if (!pathname) {
throw new Error('pathname is undefined')
}
// Used in development to check public directory paths
if (await this._beforeCatchAllRender(req, res, params, parsedUrl)) {
return {
finished: true,
}
}
if (params && params.path && params.path[0] === 'api') {
const handled = await this.handleApiRequest(
req as NextApiRequest,
res as NextApiResponse,
pathname!
)
if (handled) {
return { finished: true }
}
}
await this.render(req, res, pathname, query, parsedUrl)
return {
finished: true,
}
},
})
}
if (this.nextConfig.useFileSystemPublicRoutes) {
this.dynamicRoutes = this.getDynamicRoutes()
......@@ -479,32 +507,16 @@ export default class Server {
// (but it should support as many params as needed, separated by '/')
// Otherwise this will lead to a pretty simple DOS attack.
// See more: https://github.com/zeit/next.js/issues/2617
routes.push({
match: route('/:path*'),
type: 'route',
name: 'Catchall render',
fn: async (req, res, params, parsedUrl) => {
const { pathname, query } = parsedUrl
if (!pathname) {
throw new Error('pathname is undefined')
}
// Used in development to check public directory paths
if (await this._beforeCatchAllRender(req, res, params, parsedUrl)) {
return {
finished: true,
}
}
await this.render(req, res, pathname, query, parsedUrl)
return {
finished: true,
}
},
})
routes.push(catchAllRoute)
}
return routes
return {
routes,
fsRoutes,
catchAllRoute,
dynamicRoutes: this.dynamicRoutes,
pageChecker: this.hasPage.bind(this),
}
}
private async getPagePath(pathname: string) {
......@@ -564,7 +576,7 @@ export default class Server {
}
if (!pageFound) {
return this.render404(req, res)
return false
}
// Make sure the page is built before getting the path
// or else it won't be in the manifest yet
......@@ -575,11 +587,13 @@ export default class Server {
if (!this.renderOpts.dev && this._isLikeServerless) {
if (typeof pageModule.default === 'function') {
return pageModule.default(req, res)
await pageModule.default(req, res)
return true
}
}
await apiResolver(req, res, params, pageModule, this.onErrorMiddleware)
return true
}
protected generatePublicRoutes(): Route[] {
......
......@@ -16,6 +16,7 @@ type RouteResult = {
export type Route = {
match: RouteMatch
type: string
check?: boolean
statusCode?: number
name: string
fn: (
......@@ -26,10 +27,39 @@ export type Route = {
) => Promise<RouteResult> | RouteResult
}
export type DynamicRoutes = Array<{ page: string; match: RouteMatch }>
export type PageChecker = (pathname: string) => Promise<boolean>
export default class Router {
routes: Route[]
constructor(routes: Route[] = []) {
fsRoutes: Route[]
catchAllRoute: Route
pageChecker: PageChecker
dynamicRoutes: DynamicRoutes
constructor({
routes = [],
fsRoutes = [],
catchAllRoute,
dynamicRoutes = [],
pageChecker,
}: {
routes: Route[]
fsRoutes: Route[]
catchAllRoute: Route
dynamicRoutes: DynamicRoutes | undefined
pageChecker: PageChecker
}) {
this.routes = routes
this.fsRoutes = fsRoutes
this.pageChecker = pageChecker
this.catchAllRoute = catchAllRoute
this.dynamicRoutes = dynamicRoutes
}
setDynamicRoutes(routes: DynamicRoutes = []) {
this.dynamicRoutes = routes
}
add(route: Route) {
......@@ -41,8 +71,20 @@ export default class Router {
res: ServerResponse,
parsedUrl: UrlWithParsedQuery
): Promise<boolean> {
// memoize page check calls so we don't duplicate checks for pages
const pageChecks: { [name: string]: boolean } = {}
const memoizedPageChecker = async (p: string): Promise<boolean> => {
if (pageChecks[p]) {
return pageChecks[p]
}
const result = await this.pageChecker(p)
pageChecks[p] = result
return result
}
let parsedUrlUpdated = parsedUrl
for (const route of this.routes) {
for (const route of [...this.fsRoutes, ...this.routes]) {
const newParams = route.match(parsedUrlUpdated.pathname)
// Check if the match function matched
......@@ -62,6 +104,54 @@ export default class Router {
if (result.pathname) {
parsedUrlUpdated.pathname = result.pathname
}
// check filesystem
if (route.check === true) {
for (const fsRoute of this.fsRoutes) {
const fsParams = fsRoute.match(parsedUrlUpdated.pathname)
if (fsParams) {
const result = await fsRoute.fn(
req,
res,
fsParams,
parsedUrlUpdated
)
if (result.finished) {
return true
}
}
}
let matchedPage = await memoizedPageChecker(
parsedUrlUpdated.pathname!
)
// If we didn't match a page check dynamic routes
if (!matchedPage) {
for (const dynamicRoute of this.dynamicRoutes) {
if (dynamicRoute.match(parsedUrlUpdated.pathname)) {
matchedPage = true
}
}
}
// Matched a page or dynamic route so render it using catchAllRoute
if (matchedPage) {
const pageParams = this.catchAllRoute.match(
parsedUrlUpdated.pathname
)
await this.catchAllRoute.fn(
req,
res,
pageParams as Params,
parsedUrlUpdated
)
return true
}
}
}
}
......
......@@ -21,7 +21,7 @@ import {
} from '../next-server/lib/router/utils'
import Server, { ServerConstructor } from '../next-server/server/next-server'
import { normalizePagePath } from '../next-server/server/normalize-page-path'
import { route, Params } from '../next-server/server/router'
import Router, { route, Params } from '../next-server/server/router'
import { eventVersion } from '../telemetry/events'
import { Telemetry } from '../telemetry/storage'
import ErrorDebug from './error-debug'
......@@ -186,6 +186,7 @@ export default class DevServer extends Server {
page,
match: getRouteMatcher(getRouteRegex(page)),
}))
this.router.setDynamicRoutes(this.dynamicRoutes)
if (!resolved) {
resolve()
......@@ -212,8 +213,7 @@ export default class DevServer extends Server {
const { redirects, rewrites } = this.customRoutes
if (redirects.length || rewrites.length) {
// TODO: don't reach into router instance
this.router.routes = this.generateRoutes()
this.router = new Router(this.generateRoutes())
}
}
......@@ -330,11 +330,17 @@ export default class DevServer extends Server {
}
generateRoutes() {
const routes = super.generateRoutes()
const {
routes,
fsRoutes,
catchAllRoute,
dynamicRoutes,
pageChecker,
} = super.generateRoutes()
// In development we expose all compiled files for react-error-overlay's line show feature
// We use unshift so that we're sure the routes is defined before Next's default routes
routes.unshift({
fsRoutes.unshift({
match: route('/_next/development/:path*'),
type: 'route',
name: '_next/development catchall',
......@@ -347,7 +353,7 @@ export default class DevServer extends Server {
},
})
return routes
return { routes, fsRoutes, catchAllRoute, dynamicRoutes, pageChecker }
}
// In development public files are not added to the router but handled as a fallback instead
......
......@@ -23,6 +23,14 @@ module.exports = {
source: '/second',
destination: '/hello-again',
},
{
source: '/to-hello',
destination: '/hello',
},
{
source: '/blog/post-1',
destination: '/blog/post-2',
},
{
source: '/test/:path',
destination: '/:path',
......@@ -35,6 +43,10 @@ module.exports = {
source: '/params/:something',
destination: '/with-params',
},
{
source: '/hidden/_next/:path*',
destination: '/_next/:path*',
},
]
},
async redirects() {
......
import { useRouter } from 'next/router'
const Page = () => (
<>
<p>post: {useRouter().query.post}</p>
</>
)
Page.getInitialProps = () => ({ hello: 'world' })
export default Page
import Link from 'next/link'
export default () => (
const Page = () => (
<>
<h3 id="hello">Hello</h3>
<Link href="/nav">
......@@ -8,3 +8,7 @@ export default () => (
</Link>
</>
)
Page.getInitialProps = () => ({ hello: 'world' })
export default Page
......@@ -23,6 +23,7 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
let appDir = join(__dirname, '..')
const nextConfigPath = join(appDir, 'next.config.js')
let nextConfigContent
let buildId
let stdout = ''
let appPort
let app
......@@ -152,6 +153,31 @@ const runTests = (isDev = false) => {
expect(await getBrowserBodyText(browser)).toMatch(/Hello again/)
})
it('should match a page after a rewrite', async () => {
const html = await renderViaHTTP(appPort, '/to-hello')
expect(html).toContain('Hello')
})
it('should match dynamic route after rewrite', async () => {
const html = await renderViaHTTP(appPort, '/blog/post-1')
expect(html).toMatch(/post:.*?post-2/)
})
it('should match public file after rewrite', async () => {
const data = await renderViaHTTP(appPort, '/blog/data.json')
expect(JSON.parse(data)).toEqual({ hello: 'world' })
})
it('should match /_next file after rewrite', async () => {
await renderViaHTTP(appPort, '/hello')
const data = await renderViaHTTP(
appPort,
`/hidden/_next/static/${buildId}/pages/hello.js`
)
expect(data).toContain('Hello')
expect(data).toContain('createElement')
})
it('should allow redirecting to external resource', async () => {
const res = await fetchViaHTTP(appPort, '/to-external', undefined, {
redirect: 'manual',
......@@ -166,6 +192,11 @@ const runTests = (isDev = false) => {
const manifest = await fs.readJSON(
join(appDir, '.next/routes-manifest.json')
)
for (const route of manifest.dynamicRoutes) {
route.regex = normalizeRegEx(route.regex)
}
expect(manifest).toEqual({
version: 1,
redirects: [
......@@ -285,6 +316,18 @@ const runTests = (isDev = false) => {
regex: normalizeRegEx('^\\/second$'),
regexKeys: [],
},
{
destination: '/hello',
regex: normalizeRegEx('^\\/to-hello$'),
regexKeys: [],
source: '/to-hello',
},
{
destination: '/blog/post-2',
regex: normalizeRegEx('^\\/blog\\/post-1$'),
regexKeys: [],
source: '/blog/post-1',
},
{
source: '/test/:path',
destination: '/:path',
......@@ -305,8 +348,21 @@ const runTests = (isDev = false) => {
regex: normalizeRegEx('^\\/params(?:\\/([^\\/]+?))$'),
regexKeys: ['something'],
},
{
destination: '/_next/:path*',
regex: normalizeRegEx(
'^\\/hidden\\/_next(?:\\/((?:[^\\/]+?)(?:\\/(?:[^\\/]+?))*))?$'
),
regexKeys: ['path'],
source: '/hidden/_next/:path*',
},
],
dynamicRoutes: [
{
page: '/blog/[post]',
regex: normalizeRegEx('^\\/blog\\/([^/]+?)(?:\\/)?$'),
},
],
dynamicRoutes: [],
})
})
......@@ -321,7 +377,7 @@ const runTests = (isDev = false) => {
for (const route of [...manifest.redirects, ...manifest.rewrites]) {
expect(cleanStdout).toMatch(
new RegExp(`${route.source}.*?${route.destination}`)
new RegExp(`${route}.*?${route.destination}`)
)
}
})
......@@ -333,6 +389,7 @@ describe('Custom routes', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
buildId = 'development'
})
afterAll(() => killApp(app))
runTests(true)
......@@ -346,6 +403,7 @@ describe('Custom routes', () => {
stdout = buildStdout
appPort = await findPort()
app = await nextStart(appDir, appPort)
buildId = await fs.readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
})
afterAll(() => killApp(app))
runTests()
......@@ -369,6 +427,7 @@ describe('Custom routes', () => {
stdout += msg
},
})
buildId = await fs.readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
})
afterAll(async () => {
await killApp(app)
......
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