From 681ce7b600e5ef26f384a158e56d009763e94ea2 Mon Sep 17 00:00:00 2001 From: Adam Schwartz Date: Fri, 5 Jun 2020 15:13:45 -0400 Subject: [PATCH] =?UTF-8?q?serve=20text/html=20with=20utf8=20charset,=20re?= =?UTF-8?q?store=20=C2=B7=20(#403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.html | 2 +- workers-site/index.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 620bbd45..a9cf939d 100644 --- a/src/index.html +++ b/src/index.html @@ -5,7 +5,7 @@ - Is BGP safe yet? - Cloudflare + Is BGP safe yet? ยท Cloudflare diff --git a/workers-site/index.js b/workers-site/index.js index b184dc82..e5078352 100644 --- a/workers-site/index.js +++ b/workers-site/index.js @@ -84,6 +84,13 @@ async function handleEvent(event) { // Allow headers to be altered const response = new Response(page.body, page) + // // Manually adding utf8 charset for now since kv-asset-handler + // has it fixed (https://git.io/Jf1aQ) but it's not yet in a release + const contentType = response.headers.get('content-type') + if (contentType.startsWith('text')) { + response.headers.set('content-type', contentType + '; charset=utf8') + } + if (url.pathname === '/' || url.pathname === '/index.html') { response.headers.set('Cache-Control', 'public; max-age=60') response.headers.set('Content-Security-Policy', "default-src 'none'; script-src 'self' data: 'unsafe-inline'; object-src 'none'; style-src 'self' ui.components.workers.dev; img-src 'self'; media-src 'none'; frame-src 'none'; font-src 'none'; connect-src 'self' invalid.rpki.cloudflare.com valid.rpki.cloudflare.com")