4 ms·
Yes it is! You can make arbitrary requests in your Worker to anywhere on the internet you like, and return any response you like.
by zackbloom 9y ago
Yes it is! You can make arbitrary requests in your Worker to anywhere on the internet you like, and return any response you like.
- thefounder 9y agoThe JS requests are limited to several MBs so you can't download large assets. This applies on AWS Edge too but on AWS you can modify the request's origin and then cloudfront agent (which has higher limits ) will perform the actual request using the origin you set.
- kentonv 9y agoThe Workers runtime fully supports streaming requests/responses. If you're just passing the response through, it does not get buffered in the worker, and it is not subject to the Worker's memory limit. You can absolutely download multi-gigabyte files through a Worker.
- kentonv 9y agoTo expand on that, when you invoke fetch() and get a Response object back, that object is returned as soon as response headers have been received; it does not wait for the body. The Response object contains a ReadableStream from which you can read the body, but if you instead pass the response directly to event.respondWith(), then it will stream right back out to the client.