From 67217560aadd6b96a585aaf2623ba9b103123d5a Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Fri, 1 Nov 2024 22:28:39 -0700 Subject: [PATCH 1/4] Extract directory-only styles --- index.html | 1 + src/components/style.directory.js | 3 +++ src/components/style.js | 3 --- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 src/components/style.directory.js diff --git a/index.html b/index.html index 4991386..ef95370 100644 --- a/index.html +++ b/index.html @@ -55,6 +55,7 @@ + diff --git a/src/components/style.directory.js b/src/components/style.directory.js new file mode 100644 index 0000000..5042805 --- /dev/null +++ b/src/components/style.directory.js @@ -0,0 +1,3 @@ +import "/assets/css/search.scss"; +import "/assets/css/category-buttons.scss"; +import "/assets/css/table.scss"; diff --git a/src/components/style.js b/src/components/style.js index 35a5c81..66e39fe 100644 --- a/src/components/style.js +++ b/src/components/style.js @@ -1,7 +1,4 @@ import "/assets/css/root.scss"; import "/assets/css/page.scss"; import "/assets/css/navbar.scss"; -import "/assets/css/search.scss"; -import "/assets/css/category-buttons.scss"; -import "/assets/css/table.scss"; import "/assets/css/footer.scss"; From b9c7fa850a6ca4045807f4b1f1b622feefbd3917 Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Fri, 1 Nov 2024 22:28:51 -0700 Subject: [PATCH 2/4] Add error pages --- 502.html | 27 +++++++++++++++++++++++++++ 503.html | 27 +++++++++++++++++++++++++++ src/components/style.error.js | 1 + vite.config.js | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 502.html create mode 100644 503.html create mode 100644 src/components/style.error.js diff --git a/502.html b/502.html new file mode 100644 index 0000000..8e4411d --- /dev/null +++ b/502.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + Bad Gateway | 2FA Directory + + + + +
+

502

+

Bad Gateway

+
+ + + + + + + diff --git a/503.html b/503.html new file mode 100644 index 0000000..ae75b70 --- /dev/null +++ b/503.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + Service Unavailable | 2FA Directory + + + + +
+

503

+

Service Unavailable

+
+ + + + + + + diff --git a/src/components/style.error.js b/src/components/style.error.js new file mode 100644 index 0000000..2fb01a4 --- /dev/null +++ b/src/components/style.error.js @@ -0,0 +1 @@ +import "/assets/css/error.scss"; diff --git a/vite.config.js b/vite.config.js index 6ddf98a..a3e03a4 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,6 +15,8 @@ export default defineConfig({ rollupOptions: { input: { main: resolve(__dirname, "index.html"), + 502: resolve(__dirname, "502.html"), + 503: resolve(__dirname, "503.html"), }, }, cssCodeSplit: true, // This is the default behavior From 24c438ba87d4cfc44497a6179ca52190b792b444 Mon Sep 17 00:00:00 2001 From: Carlgo11 Date: Mon, 4 Nov 2024 03:00:31 +0100 Subject: [PATCH 3/4] Fix redirect function --- functions/redirect.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/redirect.js b/functions/redirect.js index d8f0b6b..1935501 100644 --- a/functions/redirect.js +++ b/functions/redirect.js @@ -8,7 +8,6 @@ export async function onRequestGet({ request }) { const country = request.cf?.country?.toLowerCase(); const res = await fetch(`${api}${country}/categories.json`, { method: 'HEAD', - cache: 'force-cache', cf: { cacheTtlByStatus: { "200": 60 * 60 * 24 * 14, // Cache request 2 weeks @@ -17,7 +16,7 @@ export async function onRequestGet({ request }) { } }); - let uri = res.status !== 200 ? `${base}${country}/` : `${base}/int/` + let uri = res.status === 200 ? `${base}${country}/` : `${base}int/` const params = url.searchParams.toString(); if (params) uri += `?${params}`; @@ -25,6 +24,6 @@ export async function onRequestGet({ request }) { return Response.redirect(uri, redirectStatus); } catch (e) { console.error(e); - return Response.redirect(`${base}/502/`, redirectStatus); + return Response.redirect(`${base}502/`, redirectStatus); } } From 53e394ffd7b2ad560d7002cbf86066af2a90b936 Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Sun, 3 Nov 2024 21:47:17 -0800 Subject: [PATCH 4/4] Remove 503 error page --- 503.html | 27 --------------------------- vite.config.js | 1 - 2 files changed, 28 deletions(-) delete mode 100644 503.html diff --git a/503.html b/503.html deleted file mode 100644 index ae75b70..0000000 --- a/503.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - Service Unavailable | 2FA Directory - - - - -
-

503

-

Service Unavailable

-
- - - - - - - diff --git a/vite.config.js b/vite.config.js index a3e03a4..ebab9d9 100644 --- a/vite.config.js +++ b/vite.config.js @@ -16,7 +16,6 @@ export default defineConfig({ input: { main: resolve(__dirname, "index.html"), 502: resolve(__dirname, "502.html"), - 503: resolve(__dirname, "503.html"), }, }, cssCodeSplit: true, // This is the default behavior