1

I need to get 'https' protocol.

I find h3 module return a protocol using getRequestprotocol(event).

// e.g.

import { getRequestProtocol } from 'h3'

if (process.server) {
  console.log(getRequestProtocol(useNuxtApp().ssrContext.event))
}

But, It returns 'http' even though my site's protocol is 'https'. (https://locolhost:3000)

I set mkcert to open my site with 'https' in the local development environment. Is the problem because of it?

How can I fix this? I want to get 'https' at 'https://locolhost:3000' while 'http' at 'http://localhost:3000'

This is my package.json file in my project.

// package.json

"scripts": {
  "build-dev": "ABC_ENV=development nuxt build",
  "build": "ABC_ENV=production nuxt build",
  "dev": "nuxt dev",
  "dev-https": "NODE_TLS_REJECT_UNAUTHORIZED=0 nuxt dev --https --ssl-cert ./certs/localhost.pem --ssl-key ./certs/localhost-key.pem",
  "generate": "nuxt generate",
  "preview": "nuxt preview",
  "postinstall": "nuxt prepare"
}
LSS
  • 57
  • 3

0 Answers0