From b7fe23400525d645a5db4f43683ea712f7655342 Mon Sep 17 00:00:00 2001 From: Kyle Holmberg Date: Mon, 27 Aug 2018 03:28:54 -0700 Subject: [PATCH] 404 routing for static export without exportPathMap (#5036) Resolves #5035 Thanks a billion to @timneutkens for holding my hand --- server/export.js | 6 ++++++ test/integration/static/test/ssr.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/server/export.js b/server/export.js index 3f74303a..eacb95a1 100644 --- a/server/export.js +++ b/server/export.js @@ -31,6 +31,12 @@ export default async function (dir, options, configuration) { if (page === '/_document' || page === '/_app') { continue } + + if (page === '/_error') { + defaultPathMap['404'] = { page } + continue + } + defaultPathMap[page] = { page } } diff --git a/test/integration/static/test/ssr.js b/test/integration/static/test/ssr.js index e291e900..07c60240 100644 --- a/test/integration/static/test/ssr.js +++ b/test/integration/static/test/ssr.js @@ -48,5 +48,10 @@ export default function (context) { const $ = cheerio.load(html) expect($('img').attr('src')).toBe('/static/myimage.png') }) + + it('should render _error on 404', async () => { + const html = await renderViaHTTP(context.port, '/404') + expect(html).toMatch(/404/) + }) }) }