Skip to content

Commit 3f5adb1

Browse files
authored
Merge pull request #2910 from codecrafters-io/vercel-404-fix
Send `_empty.html` instead of 404 in prerender functions if FastBoot status code was not 200
2 parents 108115a + 3dade1b commit 3f5adb1

File tree

1 file changed

+4
-7
lines changed
  • vercel-functions/prerender/_prerender-ember-route.func

1 file changed

+4
-7
lines changed

vercel-functions/prerender/_prerender-ember-route.func/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,14 @@ export default async function prerenderEmberRoute(request, response) {
3131
// Parse status code
3232
const statusCode = result._fastbootInfo.response.statusCode;
3333

34-
// Redirect to 404 page if the status code is not 200
34+
// Render a generic page if the status code is not 200
3535
if (statusCode !== 200) {
3636
console.warn('FastBoot response statusCode was:', statusCode);
37-
response.redirect('/404');
37+
response.send(fs.readFileSync('dist/_empty.html', 'utf-8'));
3838

3939
return;
4040
}
4141

42-
// Get the HTML content of the FastBoot response
43-
const html = await result['html'](); // Weird VSCode syntax highlighting issue if written as result.html()
44-
45-
// Send the HTML content as result
46-
response.send(html);
42+
// Get the HTML content of the FastBoot response & send it as result
43+
response.send(await result.html());
4744
}

0 commit comments

Comments
 (0)