Skip to content

Instantly share code, notes, and snippets.

@Zertz
Last active September 22, 2018 14:28
Show Gist options
  • Save Zertz/8347dbd5faef3ec8d7c9b477806a2d94 to your computer and use it in GitHub Desktop.
Save Zertz/8347dbd5faef3ec8d7c9b477806a2d94 to your computer and use it in GitHub Desktop.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const response = await fetch(
request.url.replace("https://fonts.jirafe.io", "https://fonts.googleapis.com"),
request
);
const css = await response.text();
return new Response(css.replace(/}/g, "font-display: swap; }"), {
headers: response.headers
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment