nitro icon indicating copy to clipboard operation
nitro copied to clipboard

http 2 support on node server

Open huang-julien opened this issue 2 years ago • 1 comments

Reproduction

import '#internal/nitro/virtual/polyfill'
import {createSecureServer, createServer, Http2ServerRequest, Http2ServerResponse} from 'http2'
import destr from 'destr'
import { nitroApp } from '../app'
import { useRuntimeConfig } from '#internal/nitro'

const cert = process.env.NITRO_SSL_CERT
const key = process.env.NITRO_SSL_KEY

// @ts-ignore
const server = createSecureServer({ key, cert }, nitroApp.h3App.nodeHandler)

const port = (destr(process.env.NITRO_PORT || process.env.PORT) || 3000) as number
const hostname = process.env.NITRO_HOST || process.env.HOST || '0.0.0.0'

// @ts-ignore
server.listen(port, hostname, (err) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  const protocol = 'https'
  console.log(`Listening on ${protocol}://${hostname}:${port}${useRuntimeConfig().app.baseURL}`)
})

if (process.env.DEBUG) {
  process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection]', err))
  process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException]', err))
} else {
  process.on('unhandledRejection', err => console.error('[nitro] [dev] [unhandledRejection] ' + err))
  process.on('uncaughtException', err => console.error('[nitro] [dev] [uncaughtException] ' + err))
}

export default {}

Describe the bug

not a bug but a feature request to add the support of http 2. Currently the node-server preset does not support the http 2 protocol.

Additional context

No response

Logs

No response

huang-julien avatar May 27 '22 22:05 huang-julien

h3 doesn't support http2 afaik. This should be the related issue: https://github.com/unjs/h3/issues/73

itpropro avatar Oct 15 '22 16:10 itpropro