workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

fetch throws error when run locally

Open step135 opened this issue 1 year ago • 4 comments

If I run npx wrangler dev and have fetch(url) in some script, it fails with following error: workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = unable to get local issuer certificate

step135 avatar Jan 23 '24 17:01 step135

Hey! 👋 Are you trying to send a request to a server using a self-signed certificate? If so, you'll need to set the NODE_EXTRA_CA_CERTS environment variable to point to your certificate so it gets trusted. Alternatively, if you're using Cloudflare WARP, make sure you've set this variable to point to the Cloudflare certificate.

mrbbot avatar Jan 23 '24 17:01 mrbbot

I don't know anything that I should create self-signed certificate. The documentation is silent about this. Why doesn't it work without any extra settings as in Node?

step135 avatar Jan 24 '24 09:01 step135

What is the URL of the website you're trying to fetch()?

mrbbot avatar Jan 24 '24 10:01 mrbbot

@step135 - please could you create a reproduction that we can run locally to diagnose the problem?

petebacondarwin avatar Feb 16 '24 14:02 petebacondarwin

hi @step135 :) we haven't heard from you in a while, so we’re going to close this issue for now, but if this is still a problem, please feel free to open a new issue referencing this one. please be sure to include an updated summary and a reproduction and we will revisit and investigate further. thanks!

lrapoport-cf avatar Mar 04 '24 16:03 lrapoport-cf