Skip to content

Commit d8ecf7c

Browse files
committed
demo
1 parent a466041 commit d8ecf7c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/content/docs/turnstile/tutorials/conditionally-enforcing-turnstile.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff 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"
8484
async 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+
```

0 commit comments

Comments
 (0)