A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members).

Foreign Fetch

From WHATWG Wiki
Jump to: navigation, search

This is a proposal for invoking service workers for requests that are same-origin with the service worker fetched from cross-origin clients.

Modifications to Fetch

...

On the face of it, it seems step 3, substep 5, of https://fetch.spec.whatwg.org/#http-fetch, needs modifications to check for a foreign fetch enabled service worker before going to the cache/network.

There also needs to be some kind of limit imposed so you can't get infinitely nested service workers (or loops). What exactly is best here is unclear.

API

[Constructor (DOMString type, optional ForeignFetchEventInit eventInitDict),
 Exposed=ServiceWorker]
interface ForeignFetchEvent : ExtendableEvent {
  readonly attribute Request request;
};

dictionary ForeignFetchEventInit : ExtendableEventInit {
  required Request request;
};

partial interface ServiceWorkerRegistration {
  Promise<void> enableForeignFetch();
  Promise<void> disableForeignFetch();
);

Note: We cannot extend FetchEvent because that exposes client and messaging functionality which might lead to security issues since current practice is all same-origin messaging when it comes to service workers.

Link header

Link:</sw.js>;rel=serviceworker;scope=/;handles=fetch,foreignfetch,push