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

http 2 support on node server #258

Open
huang-julien opened this issue May 27, 2022 · 1 comment
Open

http 2 support on node server #258

huang-julien opened this issue May 27, 2022 · 1 comment

Comments

@huang-julien
Copy link
Contributor

huang-julien commented May 27, 2022

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 huang-julien changed the title node-http2 Preset http 2 support on node server May 28, 2022
@itpropro
Copy link
Contributor

h3 doesn't support http2 afaik. This should be the related issue: unjs/h3#73

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

Successfully merging a pull request may close this issue.

3 participants