[whatwg/fetch] Proposal: Expose `initiator` to JavaScript (Issue #1430)

The specification talks about the [`initiator`](https://fetch.spec.whatwg.org/#concept-request-initiator) but it's not exposed to JavaScript. At [StackBlitz](https://stackblitz.com/) we have a concrete use case for [WebContainer](https://blog.stackblitz.com/posts/introducing-webcontainers) to run Node.js natively in the browser. More specifically, when intercepting fetch requests in a service worker, it would be very ideal to access the `initiator` because we need to implement a custom cache layer (e.g. prefetch cache) inside the service worker. In our use case, requests to `localhost` will never reach the browser's native network layer and are sent to the Node process (the server) running in another tab. To be able to implement e.g. the prefetch cache we'd have to know whether the request was initiated by `rel=prefetch`.

My suggestion would be to expose the `initiator` property on the request object.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1430
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1430@github.com>

Received on Friday, 29 April 2022 08:05:02 UTC