i.wont.tell
i.wont.tell
CDCloudflare Developers
Created by i.wont.tell on 4/15/2024 in #general-help
How to reset turnstile widget?
thank you! this is why I was seeing the error message for a few seconds and then it was gone
3 replies
CDCloudflare Developers
Created by i.wont.tell on 4/15/2024 in #general-help
How to reset turnstile widget?
so should I not be assigning any function? I currently have it like this:
turnstile.ready(function () {
turnstile.render(".widget", {
sitekey: "xxxxxxxxxxxxxxxxxxxx",
callback: turnstileSuccess,
"error-callback": turnstileError,
"expired-callback": turnstileError,
"timeout-callback": turnstileError,
"unsupported-callback": turnstileError,
});
});
turnstile.ready(function () {
turnstile.render(".widget", {
sitekey: "xxxxxxxxxxxxxxxxxxxx",
callback: turnstileSuccess,
"error-callback": turnstileError,
"expired-callback": turnstileError,
"timeout-callback": turnstileError,
"unsupported-callback": turnstileError,
});
});
3 replies
CDCloudflare Developers
Created by i.wont.tell on 4/8/2024 in #general-help
Problem(?) with the turnstile widget
ooh thank you, I thought I misconfigured something
5 replies
CDCloudflare Developers
Created by i.wont.tell on 4/4/2024 in #workers-help
How to write python workers?
no, it's javascript, I ended up using it because I already had the logic there and only the env var retrieving was missing and just learned that I can only access env vars from functions and not from say a Vue component. I have figured out what I was doing wrong. onRequestPost receives a context object, I have to access request and env from there with context.request and so on.
8 replies
CDCloudflare Developers
Created by i.wont.tell on 4/4/2024 in #workers-help
How to write python workers?
I don't understand what I'm doing wrong, I'm following the docs, here https://developers.cloudflare.com/pages/functions/api-reference/ it says that onRequestPost does receive the request and env objects so my code should be working, right?
8 replies
CDCloudflare Developers
Created by i.wont.tell on 4/4/2024 in #workers-help
How to write python workers?
No description
8 replies
CDCloudflare Developers
Created by i.wont.tell on 4/4/2024 in #workers-help
How to write python workers?
this is the function where the exception happens:
async function handleRequest(request, env) {
const TURNSTILE_SECRET_KEY = env.TURNSTILE_SECRET_KEY;

const ip = request.headers.get("CF-Connecting-IP");

const formData = await request.formData();

const user = {};
user.name = formData.get("nombre");
user.email = formData.get("email");

const token = formData.get("cf-turnstile-response");

if (formData.get("terms")) {
user.policy = "Sí";
} else {
user.policy = "No";
}

const tokenValidated = await validateToken(ip, token, TURNSTILE_SECRET_KEY);

if (!tokenValidated) {
return new Response("Token validation failed", {status: 403});
}

await forwardMessage(user, env);

return new Response("OK", {status: 200});
}
async function handleRequest(request, env) {
const TURNSTILE_SECRET_KEY = env.TURNSTILE_SECRET_KEY;

const ip = request.headers.get("CF-Connecting-IP");

const formData = await request.formData();

const user = {};
user.name = formData.get("nombre");
user.email = formData.get("email");

const token = formData.get("cf-turnstile-response");

if (formData.get("terms")) {
user.policy = "Sí";
} else {
user.policy = "No";
}

const tokenValidated = await validateToken(ip, token, TURNSTILE_SECRET_KEY);

if (!tokenValidated) {
return new Response("Token validation failed", {status: 403});
}

await forwardMessage(user, env);

return new Response("OK", {status: 200});
}
8 replies