Weird error
# workers-help
j
Hello! im trying to allow a domain through CORS using https://developers.cloudflare.com/workers/examples/cors-header-proxy I have a frontend sitting at domainA.com that calls an api at domainB.com for some reason I get this whenever a request fails
Copy code
workerd/server/server.c++:2347: error: Uncaught exception: kj/async-io-win32.c++:385: failed: WSARecv(): #64 The specified network name is no longer available.
stack: 7ff680e88950 0 0 0 0
doesnt seem like its a workers issue since stack overflow wasnt helpful but also I may be doing this all wrong (exact code https://pastebin.com/dT4G1xnE)
i
Are you getting this error consistently? Does a redeploy of the Worker fix it?
And are you publishing the Worker or is this in local development with Wrangler?
j
Local dev with wrangler
Hello world with wrangler works fine
Maybe I’m doing the whole CORS thing wrong)
i
This seems to be an issue with the local Worker simulator (workerd) - can you try restarting your PC?
e
You on Windows by the way? That error sounds very similar to one that Windows would throw
j
Yah I did. Probably windows is to blame
e
Ah
j
Hey erisa!
e
Hi
Internet seems to think it has something to do with SMB but not sure if thats relevant, windows errors are not known for being well documented
j
That’s what I saw too
boots into pop instead
System76 > Microsoft
e
Haha
j
Well thanks y’all! Btw is this how I’m supposed to go about this cross origin thing?
I have a project and I decided to build it on workers for fun
i
Basically, for any response sent by Domain B, you need to add the following headers:
"Access-Control-Allow-Methods": "POST,GET"
or other methods you use
"Access-Control-Allow-Headers": "Content-Type"
or other headers you use (such as Authorization)
"Access-Control-Allow-Origin": "domaina.com"
or other domains you call from
e
You can bypass the local runtime by using
wrangler dev --remote
btw
i
Those headers need to be returned on all responses returned from that domain, including OPTIONS method
j
Oh interesting , thanks!
Hmm alright, so there’s a preflight request that hits options, and if it has the correct header then the post request is made?
i
Yup. And those headers also need to be returned on the POST (both on the preflight, OPTIONS, as well as the final POST request) otherwise the browser will reject it
j
This seems like basic web dev that I just glossed over lol. Thanks for all ur help
Ahh okay
i
No worries, CORS can be confusing. 🙂
j
Yeah now I’m looking in chrome console and it’s complaining about cors
i
If you open the Network tab, Chrome should also tell you which request is failing (the OPTIONS or the POST) too
j
Hey Isaac, on your blog what does it mean when you advertise routes? Like why do you need to do it?
Yah that’s what I was looking at earlier and I thought for a sec it was related to the workers runtime error then spent 10 minutes realizing that windows is just.. windows and everything breaks lol
i
Oh. So basically, when you go to a web page, the network connection may go through multiple providers:
Your Internet Service Provider -> possibly through many different providers, like other ISPs in your area -> the final destination, like Cloudflare.
I have my own IP addresses (well, on loan from a friend but I can use them as I like). In order to make sure other people can reach my addresses, I "advertise routes" which means I tell people "hey if you want to reach me you can jump through this provider and then this other provider and then get to me". Like:
Your ISP -> in my case, via GoCodeIT (an ISP of sorts) -> me
That way I can control exactly how people reach my internet, and if my upstream provider goes down (GoCodeIT) I can just switch providers or even have it automatically use another one so that I don't have downtime.
j
Dude that’s sick!
i
Yeah it's pretty neat! It's how the internet works in general - if Cloudflare stopped advertising routes, suddenly all your devices wouldn't know how to reach any site on Cloudflare. Similarly, Cloudflare can change how they advertise routes to make things faster or more optimized for users.
Basically, advertising your own routes allows you more control than just using one ISP.
j
I remember reading about that one time a router was misconfigured and cloudflare disappeared from the internet
i
Exactly! That was an issue with their route advertisements.
j
Ohh that makes sense

https://youtu.be/wMRaKtydILI

Wait I found the video!
Cf employees probably sweating while watching it
b
I am getting similar error for Workers Pages with Remix (using Windows) How do I use remote for pages like
wrangler dev --remote
this won't work
wrangler pages dev ./public --remote
s
Pages doesn't support remote mode at the moment unfortunately
b
ok, for now downgraded to wrangler 2
2 Views