@@ -47,15 +47,22 @@ export default async function handleError(error, req, res, next) {
4747 req . context = { site : site [ req . language || 'en' ] . site , builtAssets }
4848 }
4949
50- // display error on the page in development, but not in production
51- if ( process . env . NODE_ENV !== 'production' && req . context ) {
50+ // display error on the page in development and staging , but not in production
51+ if ( req . context && process . env . HEROKU_PRODUCTION_APP !== 'true' ) {
5252 req . context . error = error
5353 }
5454
5555 // Special handling for when a middleware calls `next(404)`
5656 if ( error === 404 ) {
5757 // Again, we can remove this once the 404/500 pages are ready
58- return res . status ( 404 ) . send ( await liquid . parseAndRender ( fs . readFileSync ( path . join ( process . cwd ( ) , './layouts/error-404.html' ) , 'utf8' ) , req . context ) )
58+ return res
59+ . status ( 404 )
60+ . send (
61+ await liquid . parseAndRender (
62+ fs . readFileSync ( path . join ( process . cwd ( ) , './layouts/error-404.html' ) , 'utf8' ) ,
63+ req . context
64+ )
65+ )
5966 }
6067
6168 // If the error contains a status code, just send that back. This is usually
@@ -69,7 +76,14 @@ export default async function handleError(error, req, res, next) {
6976 console . error ( error )
7077 }
7178 // Again, we can remove this once the 404/500 pages are ready
72- res . status ( 500 ) . send ( await liquid . parseAndRender ( fs . readFileSync ( path . join ( process . cwd ( ) , './layouts/error-500.html' ) , 'utf8' ) , req . context ) )
79+ res
80+ . status ( 500 )
81+ . send (
82+ await liquid . parseAndRender (
83+ fs . readFileSync ( path . join ( process . cwd ( ) , './layouts/error-500.html' ) , 'utf8' ) ,
84+ req . context
85+ )
86+ )
7387
7488 // Report to Failbot AFTER responding to the user
7589 await logException ( error , req )
0 commit comments