Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move webview captcha to api endpoint
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 036f532 commit a9dec97
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
38 changes: 0 additions & 38 deletions app/routes/captcha.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions functions/api/webview-captcha.ts
@@ -0,0 +1,28 @@
export async function onRequestGet(context: RequestContext) {
return new Response(
`<!DOCTYPE html>
<html lang="en">
<head>
<title>WebView Captcha</title>
<script async defer src="https://challenges.cloudflare.com/turnstile/v0/api.js"></script>
</head>
<body>
<div class="cf-turnstile" data-callback="returnToken" data-error-callback="handleError" data-sitekey="${context.env.TURNSTILE_SITEKEY}"></div>
<script>
function handleError(_error) {
window.flutter_inappwebview.callHandler("onToken", null);
}
function returnToken(token) {
window.flutter_inappwebview.callHandler("onToken", token);
}
</script>
</body>
</html>`,
{
headers: {
"content-type": "text/html",
},
},
);
}

0 comments on commit a9dec97

Please sign in to comment.