File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
src/content/docs/turnstile/tutorials Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export default {
3737 async fetch(request) {
3838 // ...
3939
40- + if (request.headers.get("x-bypass-turnstile") === "VerySecretValue")) {
40+ + if (request.headers.get("x-bypass-turnstile") === "VerySecretValue") {
4141+ class RemoveHandler {
4242+ element(element) {
4343+ element.remove();
@@ -82,7 +82,7 @@ The same logic must be used in both the client-side and the server-side implemen
8282
8383``` diff lang="js" title="src/index.mjs"
8484async function handlePost(request) {
85- + if (request.headers.get("x-bypass-turnstile") === "VerySecretValue")) {
85+ + if (request.headers.get("x-bypass-turnstile") === "VerySecretValue") {
8686+ return new Response('Turnstile not enforced on this request')
8787+ }
8888 // Proceed with validation as normal!
@@ -94,10 +94,16 @@ async function handlePost(request) {
9494}
9595```
9696
97- ## Best practices
97+ With these changes, Turnstile will not be enforced on requests with the header ` x-bypass-turnstile: VerySecretValue ` present.
9898
99- TBD
99+ ## Demonstration
100100
101- ## Conclusion
101+ After running ` npm run dev ` in the project folder, you can test the changes by running the following command:
102102
103- TBD
103+ ``` sh
104+ curl -X POST http://localhost:8787/handler -H " x-bypass-turnstile: VerySecretValue"
105+ ```
106+
107+ ``` txt output
108+ Turnstile not enforced on this request
109+ ```
You can’t perform that action at this time.
0 commit comments