Repository navigation
feat: gate the site behind Cloudflare Turnstile - #13
Merged
Merged
Conversation
Deploying blog with
|
| Latest commit: |
5ecadc4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0093d005.blog-7qk.pages.dev |
| Branch Preview URL: | https://feat-turnstile-gate.blog-7qk.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gate the whole blog behind Cloudflare Turnstile, ported from the bio repo.
functions/_middleware.ts(Pages Functions) serves a self-contained challenge page (401,noindex) to page loads without a validblog_sessioncookie, and a bare 401 to other requests.functions/api/verify-turnstile.tsverifies the token with Cloudflare siteverify and setsblog_session(HMAC-SHA256 signed withTURNSTILE_SECRET_KEY,HttpOnly; Secure; SameSite=Lax, 24 h)./api/*,/rss.xml, sitemaps,/robots.txt, favicons,/og.png,/astropaper-og.jpg,/posts/<slug>/index.pngand the pre-v7 OG PNG.PREVIEW=true(set on the Preview environment) leaves preview deployments open. A missing secret fails closed (500).Cloudflare (already configured): new Turnstile widget
blog(managed,blog.kulkarni.cloud+blog-7qk.pages.dev); Pages projectbloghasTURNSTILE_SITE_KEYandTURNSTILE_SECRET_KEYon Production andPREVIEW=trueon Preview.Local checks: lint 0 errors, build 27 pages, unit 71 passed (21 new in
tests/functions/turnstile.test.ts), e2e 96 passed, Lighthouse 99.8% avg. Functions do not run locally, so e2e and Lighthouse exercise the ungated site.After merge:
curl -sI https://blog.kulkarni.cloud/should return 401,/rss.xml200, and passing the widget in a browser should load the blog.