Skip to content

How to use HTTP/2 with React.JS / Next.JS!?! #4253

@khteh

Description

@khteh

Version

20.3.1

Platform

Linux khteh-p17-2i 6.2.0-33-generic nodejs/node#33-Ubuntu SMP PREEMPT_DYNAMIC Tue Sep 5 14:49:19 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

React.JS, Next.JS

What steps will reproduce the bug?

Reference: https://github.com/vercel/next.js/blob/canary/examples/with-http2/server.js

const app = next({ dev, hostname, port, dir: __dirname })
const server = http2.createSecureServer({
  key: fs.readFileSync('server.key'),
  cert: fs.readFileSync('server.crt')
})
app.prepare().then(() => {
})
    server.on('request', (req, res) => {
      console.log(`request ${req.url}`)
        app.render(req, res, req.url || '/', req.query)
      })    
    server.listen(port, (err) => {
      if (err) {
        console.error('Failed to start server', err)
        process.exit(1)
      } else {
        console.log(`HTTP/2 server listening on port: ${port}`)
      }
    })
}).catch(err => next(err))

error:

- error unhandledRejection: TypeError: Cannot read properties of undefined (reading 'end')

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

- error unhandledRejection: TypeError: Cannot read properties of undefined (reading 'end')

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions