File tree 3 files changed +12
-8
lines changed
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ module.exports = {
29
29
},
30
30
// Paths
31
31
distPath: path .resolve (__dirname , ' ./dist' ),
32
+ error500Html: null ,
32
33
templatePath: path .resolve (__dirname , ' ./dist/index.html' ),
33
34
serviceWorkerPath: path .resolve (__dirname , ' ./dist/service-worker.js' ),
34
35
// Directives fallback
Original file line number Diff line number Diff line change @@ -106,20 +106,23 @@ module.exports = (app, options) => {
106
106
httpCode : 200 ,
107
107
}
108
108
renderer . renderToString ( context , ( err , html ) => {
109
- if ( err ) {
109
+ if ( err || context . httpCode === 500 ) {
110
110
console . error ( `error during render url : ${ req . url } ` )
111
- console . error ( err )
112
111
113
112
// Render Error Page
114
113
let errorHtml = config . error500Html
115
114
? fs . readFileSync ( config . error500Html , 'utf-8' )
116
115
: '500 | Internal Server Error'
117
116
118
- if ( ! isProd ) {
119
- const errorMessage = `<pre>${ err . stack } </pre>`
120
- config . error500Html
121
- ? errorHtml = errorHtml . replace ( '<!--server-error-msg-->' , errorMessage )
122
- : errorHtml += errorMessage
117
+ if ( err ) {
118
+ console . error ( err )
119
+
120
+ if ( ! isProd ) {
121
+ const errorMessage = `<pre>${ err . stack } </pre>`
122
+ config . error500Html
123
+ ? errorHtml = errorHtml . replace ( '<!--server-error-msg-->' , errorMessage )
124
+ : errorHtml += errorMessage
125
+ }
123
126
}
124
127
125
128
res . status ( 500 ) . send ( errorHtml )
Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ module.exports = {
6
6
entry : target => `./src/entry-${ target } ` ,
7
7
defaultTitle : 'My app' ,
8
8
favicon : './public/favicon.ico' ,
9
- error500Html : null ,
10
9
skipRequests : req => req . originalUrl === '/graphql' ,
11
10
nodeExternalsWhitelist : [ / \. c s s $ / , / \? v u e & t y p e = s t y l e / ] ,
12
11
extendServer : null ,
13
12
// Paths
14
13
distPath : null ,
14
+ error500Html : null ,
15
15
templatePath : null ,
16
16
serviceWorkerPath : null ,
17
17
directives : { } ,
You can’t perform that action at this time.
0 commit comments