Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPDY > Express.JS > Next.JS don't show path details. #282

Open
khteh opened this issue Sep 7, 2023 · 0 comments
Open

SPDY > Express.JS > Next.JS don't show path details. #282

khteh opened this issue Sep 7, 2023 · 0 comments

Comments

@khteh
Copy link

khteh commented Sep 7, 2023

I am using SPDY server for HTTP/2 for my React.JS / Next.JS application. Unfortunately this solution needs to use Express.JS and therefore this is what I do to have request logging:

    // Init the Next app:
    const app = next({ dev, dir: __dirname })
    const handle = app.getRequestHandler()
const options = {
  key: fs.readFileSync('server.key'),
  cert: fs.readFileSync('server.crt'),
}
app.prepare().then(() => {
    const expressApp = express()
    const format = json({
      IP: ':remote-addr',
      User: ':remote-user',
      Timestamp: ':date[clf]',
      Method: ':method',
      Path: ':url',
      Protocol: 'HTTP/:http-version',
      Status: ':status',
      ContentLength: ':res[content-length]',
      Referrer: ':referrer',
      Agent: ':user-agent',
      ResponseTime: ':response-time ms',
    })
    expressApp.use(
      logger(format, {
        stream: accessLogStream,
      })
    )
  expressApp.all('*', (req, res) => {
    return handle(req, res)
  })
   const server = spdy.createServer(options, expressApp)
  server.listen(port, (err) => {
    if (err) {
      apm.captureError(err)
      console.error('Failed to start server', err)
      process.exit(1)
    } else {
      console.log(`HTTP/2 server listening on port: ${port}`)
    }
  })
})

However, I get most of the request paths showing up as "Others" in my EFK logging dashboard:
Screenshot from 2023-09-11 16-17-58

How can I get the detailed request paths going into the Next.JS application?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant