From d3f0eeb66b55bbc9568d6f24e845e057bb5966fa Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Thu, 23 Apr 2020 17:03:31 -0700 Subject: [PATCH] comment http redirection, as this is handled by CF. Leave code as a reminder of the checkbox --- index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index fcfda2c..c732678 100644 --- a/index.js +++ b/index.js @@ -103,14 +103,15 @@ async function handleRequest(request) { const requestPath = requestUrl.pathname; let originUrl = `${originHost}${requestPath}`; let home = null; - if (requestUrl.protocol === 'http:') { - // The front-end has javascript to refresh the page after the whole - // thing has been rendered, resulting in an ugly flash. We'll do the - // redirect server (well, edge) side instead. Note this breaks debugging, - // which we can fix later because deploys are so fast that we can - // just YOLO our changes - return Response.redirect(request.url.replace(/^http/, 'https'), 301); - } + // Cloudflare offers this as a checkbox + // if (requestUrl.protocol === 'http:') { + // // The front-end has javascript to refresh the page after the whole + // // thing has been rendered, resulting in an ugly flash. We'll do the + // // redirect server (well, edge) side instead. Note this breaks debugging, + // // which we can fix later because deploys are so fast that we can + // // just YOLO our changes + // return Response.redirect(request.url.replace(/^http/, 'https'), 301); + // } if (requestPath === '/' && request.method === 'GET') { originUrl = origin; home = homePage(originHost);