Remix.run Logo
immibis 3 days ago

Why do you need libcurl to work in WebAssembly... when you're already running in a browser?

(The answer: to run third-party code that uses libcurl because it isn't designed to run in web browsers)

RandomRandy 3 days ago | parent | next [-]

One advantage over using fetch is that the WebAssembly approach seems to bypass CORS

> If you inspect the devtools network tab of your browser, you see that everything happens over a single WebSocket to wss://ws.r-universe.dev. The browser is not making the HTTP requests, in fact this would not even be possible because we download the files from a host that does not enable CORS.

roywiggins 3 days ago | parent | next [-]

You don't need websockets or wasm for that of course:

https://github.com/Shivam010/bypass-cors

As long as the browser is talking to a server that's setting the correct CORS headers, that server can of course forward those requests to whatever third party server it wants.

vk6 3 days ago | parent [-]

Classic CORS proxies are bad for privacy though. They read the contents of the forwarded requests in plain text, which might include API keys or other secrets. This is problematic though, since the typical use case for CORS proxies is if you're unable to host your own backend.

With this kind of solution, the proxy only deals with the data in the underlying TCP socket. That data will be encrypted with TLS until it gets to the destination server. In this case, you don't need to fully trust the proxy sever to use it safely.

3 days ago | parent [-]
[deleted]
aaroninsf 3 days ago | parent | prev [-]

That's... interesting!

nticompass 3 days ago | parent | prev [-]

The "real" answer: because you can.