mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
feat(nitro): ssl nitro support in production (#2742)
This commit is contained in:
parent
4b351504e8
commit
176716bdaf
@ -1,9 +1,13 @@
|
||||
import '#polyfill'
|
||||
import { Server } from 'http'
|
||||
import { Server as HttpServer } from 'http'
|
||||
import { Server as HttpsServer } from 'https'
|
||||
import destr from 'destr'
|
||||
import { handle } from '../server'
|
||||
|
||||
const server = new Server(handle)
|
||||
const cert = process.env.NITRO_SSL_CERT
|
||||
const key = process.env.NITRO_SSL_KEY
|
||||
|
||||
const server = cert && key ? new HttpsServer({ key, cert }, handle) : new HttpServer(handle)
|
||||
|
||||
const port = (destr(process.env.NUXT_PORT || process.env.PORT) || 3000) as number
|
||||
const hostname = process.env.NUXT_HOST || process.env.HOST || 'localhost'
|
||||
@ -14,7 +18,8 @@ server.listen(port, hostname, (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`Listening on http://${hostname}:${port}`)
|
||||
const protocol = cert && key ? 'https' : 'http'
|
||||
console.log(`Listening on ${protocol}://${hostname}:${port}`)
|
||||
})
|
||||
|
||||
export default {}
|
||||
|
Loading…
Reference in New Issue
Block a user