diff --git a/packages/next-server/server/next-server.js b/packages/next-server/server/next-server.js index 6d9c8b40..9ddfe439 100644 --- a/packages/next-server/server/next-server.js +++ b/packages/next-server/server/next-server.js @@ -10,9 +10,9 @@ import { serveStatic } from './render' import Router, {route} from './router' -import { isInternalUrl } from './utils' +import { isInternalUrl, isBlockedPage } from './utils' import loadConfig from 'next-server/next-config' -import {PHASE_PRODUCTION_SERVER, BLOCKED_PAGES, BUILD_ID_FILE, CLIENT_STATIC_FILES_PATH, CLIENT_STATIC_FILES_RUNTIME} from 'next-server/constants' +import {PHASE_PRODUCTION_SERVER, BUILD_ID_FILE, CLIENT_STATIC_FILES_PATH, CLIENT_STATIC_FILES_RUNTIME} from 'next-server/constants' import * as asset from '../lib/asset' import * as envConfig from '../lib/runtime-config' import { isResSent } from '../lib/utils' @@ -177,7 +177,7 @@ export default class Server { return this.handleRequest(req, res, parsedUrl) } - if (BLOCKED_PAGES.indexOf(pathname) !== -1) { + if (isBlockedPage(pathname)) { return await this.render404(req, res, parsedUrl) } diff --git a/packages/next-server/server/utils.js b/packages/next-server/server/utils.js index 58e49c4d..1edc90b3 100644 --- a/packages/next-server/server/utils.js +++ b/packages/next-server/server/utils.js @@ -1,3 +1,5 @@ +import { BLOCKED_PAGES } from 'next-server/constants' + const internalPrefixes = [ /^\/_next\//, /^\/static\// @@ -12,3 +14,7 @@ export function isInternalUrl (url) { return false } + +export function isBlockedPage (pathname) { + return (BLOCKED_PAGES.indexOf(pathname) !== -1) +}