Skip to content

Commit

Permalink
336: Update formdata to use json for siteverify (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklise authored May 13, 2024
1 parent 91ec79d commit 852c409
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lambda/permissionUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,18 @@ exports.getParkAccess = async function getParkAccess(park, permissionObject) {
exports.validateToken = async function (token) {
// Validate the token by calling the
// "/siteverify" API endpoint.
let formData = new FormData();
formData.append('secret', CF_SECRET_KEY);
formData.append('response', token);
const body = JSON.stringify({
secret: CF_SECRET_KEY,
response: token
});

const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
const result = await fetch(url, {
body: formData,
body: body,
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});

const res = await result.json();
Expand Down

0 comments on commit 852c409

Please sign in to comment.