@@ -7,11 +7,11 @@ import request from 'superagent'
77import l10n from '../client/l10n'
88import render from '../client/run-server'
99
10- const themes = [ 'light' , 'dark' ]
11- , langs = Object . keys ( l10n )
12- , baseHref = process . env . BASE_HREF || '/'
13- , canonBase = process . env . CANONICAL_URL ? process . env . CANONICAL_URL . replace ( / \/ $ / , '' ) : null
14- , apiUrl = process . env . API_URL . replace ( / \/ $ / , '' )
10+ const themes = [ 'light' , 'dark' ]
11+ , langs = Object . keys ( l10n )
12+ , baseHref = process . env . BASE_HREF || '/'
13+ , canonBase = process . env . CANONICAL_URL ? process . env . CANONICAL_URL . replace ( / \/ $ / , '' ) : null
14+ , apiUrl = process . env . API_URL . replace ( / \/ $ / , '' )
1515
1616const rpath = p => path . join ( __dirname , p )
1717
@@ -37,7 +37,7 @@ app.use((req, res, next) => {
3737 if ( ! langs . includes ( lang ) ) lang = 'en'
3838 if ( req . query . lang && req . cookies . lang !== lang ) res . cookie ( 'lang' , lang )
3939
40- render ( req . _parsedUrl . pathname , req . _parsedUrl . query || '' , req . body , { theme, lang } , ( err , resp ) => {
40+ render ( req . _parsedUrl . pathname , req . _parsedUrl . query || '' , req . body , { theme, lang, isHead : req . method === 'HEAD' } , ( err , resp ) => {
4141 if ( err ) return next ( err )
4242 if ( resp . redirect ) return res . redirect ( 301 , baseHref + resp . redirect . substr ( 1 ) )
4343 if ( resp . errorCode ) {
@@ -48,11 +48,11 @@ app.use((req, res, next) => {
4848 res . status ( resp . status || 200 )
4949 res . render ( indexView , {
5050 prerender_title : resp . title
51- , prerender_html : resp . html
52- , canon_url : canonBase ? canonBase + req . url : null
53- , noscript : true
54- , theme
55- , t : l10n [ lang ]
51+ , prerender_html : resp . html
52+ , canon_url : canonBase ? canonBase + req . url : null
53+ , noscript : true
54+ , theme
55+ , t : l10n [ lang ]
5656 } )
5757 } )
5858
@@ -64,10 +64,10 @@ if (process.env.SOCKET_PATH) {
6464 if ( fs . statSync ( process . env . SOCKET_PATH ) . isSocket ( ) ) {
6565 fs . unlinkSync ( process . env . SOCKET_PATH )
6666 }
67- } catch ( _ ) { }
67+ } catch ( _ ) { }
6868}
6969
70- app . listen ( process . env . SOCKET_PATH || process . env . PORT || 5001 , function ( ) {
70+ app . listen ( process . env . SOCKET_PATH || process . env . PORT || 5001 , function ( ) {
7171 let addr = this . address ( )
7272 if ( addr . address ) addr = `${ addr . address } :${ addr . port } `
7373 console . log ( `HTTP server running on ${ addr } ` )
0 commit comments