Skip to content

Commit

Permalink
Merge pull request #62 from tohellandback/master
Browse files Browse the repository at this point in the history
[routes-middleware] pass req to getHead
  • Loading branch information
pturchik committed Apr 17, 2020
2 parents 22f25e5 + 2eb2c40 commit 11d3148
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/routes-middleware/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const _memoize = require('lodash/memoize')
const _keys = require('lodash/keys')
const _isArray = require('lodash/isArray')
const defaultClientLayout = require('./defaultClientLayout')
Expand All @@ -13,8 +12,8 @@ module.exports = function (appRoutes, options = {}) {
if (_isArray(appRoutes)) {
appRoutes = { [DEFAULT_APP_NAME]: appRoutes }
}
// Memoize getting the end-user <head> code
const getHead = _memoize(options.getHead || (() => ''))

const getHead = options.getHead || (() => '')

return function (req, res, next) {
let matched
Expand Down Expand Up @@ -56,7 +55,7 @@ module.exports = function (appRoutes, options = {}) {
const html = (options.getClientLayout || defaultClientLayout)({
styles: process.env.NODE_ENV === 'production'
? resourceManager.getProductionStyles(appName, options) : '',
head: getHead(appName),
head: getHead(appName, req),
modelBundle: bundle,
jsBundle: resourceManager.getResourcePath('bundle', appName, options),
env: model.get('_session.env') || {}
Expand Down

0 comments on commit 11d3148

Please sign in to comment.