【问题标题】:How does one provide global properties to the render engine如何为渲染引擎提供全局属性
【发布时间】:2020-05-19 15:09:21
【问题描述】:

如何为template renderer 提供全局属性以便不在每个渲染端点中明确定义它?

例如请求调用的 url。

【问题讨论】:

    标签: nestjs server-side-rendering


    【解决方案1】:

    偶然发现了这个answer,并通过注入中间件并使用middleware consumer指定哪些路由来完美运行。

    请注意,对于 express 4.x,locals 是一个对象,而不是一个函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-05
      • 2013-06-08
      • 2014-05-03
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      相关资源
      最近更新 更多