首页 文章

新文物浏览器index.html

提问于
浏览
1

我有节点快递应用程序
我有公共文件夹/ public也添加像 app.use(express.static('./public')); 和index.html
所以当我跑步

node server.js

它显示我localhost:3000 / index.html
怎么能放入 index.html

newrelic.getBrowserTimingHeader()

在localhost:3000 / index.html NREUM 对象中查看

1 回答

  • 0

    New Relic for Node要求应用程序使用HTML模板库来注入标头 .

    他们在这里有完整的文档:https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/page-load-timing-nodejs

    要看的重要部分是示例 . 这些来自使用Express和Jade的示例文档:

    插入浏览器计时 Headers 的最简单方法是将newrelic模块传递到模板中,然后从模板中调用newrelic.getBrowsertimingHeader() .

    app.js

    var newrelic = require('newrelic');
    var app = require('express')();
    // in express, this lets you call newrelic from within a template
    app.locals.newrelic = newrelic;
    
    app.get('/user/:id', function (req, res) {
      res.render('user');
    });
    app.listen(process.env.PORT);
    

    layout.jade

    doctype html
    html
      head
        != newrelic.getBrowserTimingHeader()
        title= title
        link(rel='stylesheet', href='stylesheets/style.css')
      body
        block content
    

    newrelic 模块设置用于模板的应用程序本地的块是重要的位: app.locals.newrelic = newrelic; .

    's simply no way to run something in a static file the way Express' s static 模块默认工作 . 它几乎直接流式传输静态文件的文本内容 .

相关问题