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

Running dev in https fails on rc10 #14911

Closed
chrisnoden opened this issue Sep 15, 2022 · 6 comments
Closed

Running dev in https fails on rc10 #14911

chrisnoden opened this issue Sep 15, 2022 · 6 comments

Comments

@chrisnoden
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v16.17.0
  • Nuxt Version: 3.0.0-rc.10
  • Nitro Version: 0.5.3
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: nitro
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/chrisnoden/nuxt3-bug

  1. Create a minimal nuxt v3 project
  2. Create a cert for localhost using mkcert
  3. Run the project with npx nuxi dev --https --ssl-cert localhost.pem --ssl-key localhost-key.pem

Describe the bug

Error in browser and on terminal. Unable to use https, but http (no SSL) works.

Additional context

#14783

Logs

[nuxt] [request error] [unhandled] [500] request to https://0.0.0.0:3000/__nuxt_vite_node__/manifest failed, reason: unable to verify the first certificate ()
  at async $fetchRaw2 (./node_modules/ohmyfetch/dist/chunks/fetch.mjs:131:20)  
  at async ./.nuxt/dev/index.mjs:457:20  
  at async ./.nuxt/dev/index.mjs:526:64  
  at async ./.nuxt/dev/index.mjs:106:22  
  at async ./node_modules/h3/dist/index.mjs:592:19  
  at async Server.nodeHandler (./node_modules/h3/dist/index.mjs:538:7)
[nuxt] [request error] [unhandled] [500] request to https://0.0.0.0:3000/__nuxt_vite_node__/manifest failed, reason: unable to verify the first certificate ()
  at async $fetchRaw2 (./node_modules/ohmyfetch/dist/chunks/fetch.mjs:131:20)  
  at async ./.nuxt/dev/index.mjs:457:20  
  at async ./.nuxt/dev/index.mjs:526:64  
  at async ./.nuxt/dev/index.mjs:106:22  
  at async ./node_modules/h3/dist/index.mjs:592:19  
  at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)  
  at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async $fetchRaw2 (./node_modules/ohmyfetch/dist/chunks/fetch.mjs:131:20)  
  at async Object.errorhandler [as onError] (./.nuxt/dev/index.mjs:354:29)  
  at async Server.nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
[nuxt] [request error] [unhandled] [500] request to https://0.0.0.0:3000/__nuxt_vite_node__/manifest failed, reason: unable to verify the first certificate ()
  at async $fetchRaw2 (./node_modules/ohmyfetch/dist/chunks/fetch.mjs:131:20)  
  at async ./.nuxt/dev/index.mjs:457:20  
  at async ./.nuxt/dev/index.mjs:526:64  
  at async ./.nuxt/dev/index.mjs:106:22  
  at async ./node_modules/h3/dist/index.mjs:592:19  
  at async nodeHandler (./node_modules/h3/dist/index.mjs:538:7)  
  at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async $fetchRaw2 (./node_modules/ohmyfetch/dist/chunks/fetch.mjs:131:20)  
  at async Object.errorhandler [as onError] (./.nuxt/dev/index.mjs:354:29)  
  at async Server.nodeHandler (./node_modules/h3/dist/index.mjs:545:9)
@pi0
Copy link
Member

pi0 commented Sep 15, 2022

Hi. As mentioned in nuxt/framework#7271, for self-signed certificates, you need NODE_TLS_REJECT_UNAUTHORIZED=0 flag. Can you please try this:

NODE_TLS_REJECT_UNAUTHORIZED=0 npx nuxi dev --https --ssl-cert localhost.pem --ssl-key localhost-key.pem

@chrisnoden
Copy link
Author

Ah right, sorry. I did have a search around the various issues but didn't see that. Yes, it works with that set.

Copy link
Member

I believe this is already present in the docs: https://v3.nuxtjs.org/api/commands/dev/#nuxi-dev.

@pi0 Are you thinking of putting it somewhere else?

@pi0
Copy link
Member

pi0 commented Sep 15, 2022

It should work out of the box with RC.11+ (via nuxt/framework#7547). You can use edge channel to try this.

@chrisnoden
Copy link
Author

It should work out of the box with RC.11+ (via nuxt/framework#7547). You can use edge channel to try this.

I can confirm it does. Nice work. Thanks @pi0

@jamaluddinrumi
Copy link

jamaluddinrumi commented Jan 1, 2023

is it works for LAN?

i've tried many times but no luck

Nuxi 3.0.0                                                                                                                                            21:55:13
Nuxt 3.0.0 with Nitro 1.0.0                                                                                                                           21:55:13
                                                                                                                                                      21:55:14
  > Local:    https://localhost:3000/ 
  > Network:  https://192.168.1.127:3000/
                                                                                                                                                      21:55:13
ℹ Vite client warmed up in 14486ms                                                                                                                    21:55:30
✔ Nitro built in 610 ms                                                                                                                         nitro 21:55:31
(node:7891) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)

it always give me
Screen Shot 2023-01-01 at 10 07 03 PM

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants