Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Last active April 27, 2016 19:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakearchibald/aff93cad208bd56a02ea70f9f0d01c99 to your computer and use it in GitHub Desktop.
Save jakearchibald/aff93cad208bd56a02ea70f9f0d01c99 to your computer and use it in GitHub Desktop.
self.addEventListener('fetch', event => {
let request = event.request;
if (request.method == 'GET') {
request = new Request(request.url, {
method: 'GET',
headers: request.headers,
mode: request.mode == 'navigate' ? 'cors' : request.mode,
credentials: request.credentials,
redirect: request.redirect
});
}
// now we don't hit the FAIL after a POST redirect!
event.respondWith(
fetch(request).catch(() => new Response("FAIL"))
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment