post-deploy.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>Turnstile Spin — Deploy complete</title>
  7. <style>
  8. :root {
  9. color-scheme: light dark;
  10. --bg: #ffffff;
  11. --fg: #1d1f20;
  12. --muted: #6b6f72;
  13. --border: #e5e7eb;
  14. --accent: #f6821f;
  15. --accent-fg: #ffffff;
  16. --code-bg: #f5f5f5;
  17. --ok: #16a34a;
  18. --err: #dc2626;
  19. }
  20. @media (prefers-color-scheme: dark) {
  21. :root {
  22. --bg: #0f1010;
  23. --fg: #f1f1f1;
  24. --muted: #9aa0a3;
  25. --border: #2a2a2a;
  26. --code-bg: #1a1a1a;
  27. }
  28. }
  29. * {
  30. box-sizing: border-box;
  31. }
  32. body {
  33. font:
  34. 16px/1.5 -apple-system,
  35. "Segoe UI",
  36. Inter,
  37. system-ui,
  38. sans-serif;
  39. color: var(--fg);
  40. background: var(--bg);
  41. margin: 0;
  42. padding: 0;
  43. }
  44. main {
  45. max-width: 720px;
  46. margin: 0 auto;
  47. padding: 48px 24px 96px;
  48. }
  49. h1 {
  50. font-size: 28px;
  51. margin: 0 0 8px;
  52. letter-spacing: -0.01em;
  53. }
  54. h2 {
  55. font-size: 18px;
  56. margin: 32px 0 12px;
  57. }
  58. p {
  59. margin: 0 0 16px;
  60. color: var(--fg);
  61. }
  62. .muted {
  63. color: var(--muted);
  64. }
  65. .pill {
  66. display: inline-block;
  67. background: var(--ok);
  68. color: white;
  69. padding: 4px 10px;
  70. border-radius: 12px;
  71. font-size: 12px;
  72. font-weight: 500;
  73. margin-bottom: 16px;
  74. }
  75. .card {
  76. border: 1px solid var(--border);
  77. border-radius: 8px;
  78. padding: 20px;
  79. margin: 16px 0;
  80. background: var(--bg);
  81. }
  82. label {
  83. display: block;
  84. font-size: 13px;
  85. font-weight: 500;
  86. margin-bottom: 6px;
  87. color: var(--muted);
  88. }
  89. input[type="text"],
  90. input[type="url"] {
  91. width: 100%;
  92. padding: 8px 12px;
  93. border: 1px solid var(--border);
  94. border-radius: 6px;
  95. background: var(--bg);
  96. color: var(--fg);
  97. font-size: 14px;
  98. font-family: "SF Mono", Menlo, Consolas, monospace;
  99. }
  100. input[readonly] {
  101. background: var(--code-bg);
  102. }
  103. button {
  104. background: var(--accent);
  105. color: var(--accent-fg);
  106. border: none;
  107. border-radius: 6px;
  108. padding: 10px 18px;
  109. font-size: 14px;
  110. font-weight: 500;
  111. cursor: pointer;
  112. margin-top: 12px;
  113. }
  114. button:hover {
  115. opacity: 0.92;
  116. }
  117. button.secondary {
  118. background: transparent;
  119. color: var(--fg);
  120. border: 1px solid var(--border);
  121. }
  122. code,
  123. pre {
  124. font-family: "SF Mono", Menlo, Consolas, monospace;
  125. background: var(--code-bg);
  126. border-radius: 4px;
  127. }
  128. code {
  129. padding: 1px 5px;
  130. font-size: 13px;
  131. }
  132. pre {
  133. padding: 14px;
  134. overflow-x: auto;
  135. font-size: 13px;
  136. line-height: 1.5;
  137. border: 1px solid var(--border);
  138. }
  139. .status {
  140. margin-top: 12px;
  141. font-size: 13px;
  142. }
  143. .status.ok {
  144. color: var(--ok);
  145. }
  146. .status.err {
  147. color: var(--err);
  148. }
  149. .row {
  150. display: flex;
  151. gap: 8px;
  152. align-items: center;
  153. }
  154. .row input {
  155. flex: 1;
  156. }
  157. a {
  158. color: var(--accent);
  159. }
  160. </style>
  161. </head>
  162. <body>
  163. <main>
  164. <div class="pill">Deploy complete</div>
  165. <h1>Your Turnstile Spin backend is live.</h1>
  166. <p class="muted">
  167. This Worker is the managed siteverify backend for
  168. <a href="https://developers.cloudflare.com/turnstile/spin/">Turnstile Spin</a>.
  169. You have two remaining steps: get a site key, and paste both values
  170. into your site.
  171. </p>
  172. <h2>1. Your Worker URL</h2>
  173. <div class="card">
  174. <label for="worker-url">Worker URL (the form action / fetch target)</label>
  175. <div class="row">
  176. <input id="worker-url" type="url" readonly value="" />
  177. <button class="secondary" id="copy-worker">Copy</button>
  178. </div>
  179. <div class="status" id="health-status">Checking <code>/health</code>...</div>
  180. </div>
  181. <h2>2. Your site key</h2>
  182. <div class="card">
  183. <p>
  184. You can either reuse an existing Turnstile widget or create a new
  185. one. Both options take you through Cloudflare's dashboard; the secret
  186. never leaves your account.
  187. </p>
  188. <button
  189. id="create-widget"
  190. onclick="window.open('https://dash.cloudflare.com/?to=/:account/turnstile', '_blank')"
  191. >
  192. Create a widget in the dashboard
  193. </button>
  194. <p class="muted" style="margin-top: 16px; font-size: 13px;">
  195. After creating the widget, copy its <strong>site key</strong> (public,
  196. goes in your HTML) and its <strong>secret</strong> (private, goes in
  197. the Worker). Then run:
  198. </p>
  199. <pre>npx wrangler secret put TURNSTILE_SECRET_KEY --name turnstile-siteverify
  200. # paste the secret when prompted</pre>
  201. </div>
  202. <h2>3. Paste this into your site</h2>
  203. <div class="card">
  204. <label for="sitekey-input">Your site key</label>
  205. <input
  206. id="sitekey-input"
  207. type="text"
  208. placeholder="0x4AAAAAAA..."
  209. oninput="updateSnippet()"
  210. />
  211. <label for="snippet" style="margin-top: 16px;">HTML to paste</label>
  212. <pre id="snippet">&lt;!-- enter your site key above to generate the snippet --&gt;</pre>
  213. <button class="secondary" id="copy-snippet">Copy snippet</button>
  214. </div>
  215. <h2>Next</h2>
  216. <p>
  217. Open your site in a browser. Solve the Turnstile widget. Confirm the
  218. form submission lands at your Worker and that the network response
  219. includes <code>"success": true</code>.
  220. </p>
  221. <p class="muted" style="font-size: 13px;">
  222. If you have a codebase and a coding agent, the AI agent path is faster.
  223. See <a href="https://developers.cloudflare.com/turnstile/spin/">developers.cloudflare.com/turnstile/spin</a>.
  224. </p>
  225. </main>
  226. <script>
  227. const workerUrl = window.location.origin;
  228. document.getElementById("worker-url").value = workerUrl;
  229. document.getElementById("copy-worker").onclick = () => {
  230. navigator.clipboard.writeText(workerUrl);
  231. };
  232. fetch(workerUrl + "/health")
  233. .then((r) => r.json())
  234. .then((j) => {
  235. const el = document.getElementById("health-status");
  236. if (j.ok) {
  237. el.className = "status ok";
  238. el.innerHTML =
  239. "&#10003; Worker is healthy (version " +
  240. j.version +
  241. ")";
  242. } else {
  243. el.className = "status err";
  244. el.textContent = "Health check returned a non-ok response.";
  245. }
  246. })
  247. .catch((e) => {
  248. const el = document.getElementById("health-status");
  249. el.className = "status err";
  250. el.textContent = "Could not reach /health: " + e.message;
  251. });
  252. function updateSnippet() {
  253. const sitekey =
  254. document.getElementById("sitekey-input").value.trim() ||
  255. "YOUR_SITEKEY";
  256. const html = [
  257. '<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></sc' +
  258. "ript>",
  259. "",
  260. '<form action="' + workerUrl + '/" method="POST">',
  261. ' <div class="cf-turnstile"',
  262. ' data-sitekey="' + sitekey + '"',
  263. ' data-action="turnstile-spin-v1"></div>',
  264. ' <button type="submit">Submit</button>',
  265. "</form>",
  266. ].join("\n");
  267. document.getElementById("snippet").textContent = html;
  268. }
  269. document.getElementById("copy-snippet").onclick = () => {
  270. navigator.clipboard.writeText(
  271. document.getElementById("snippet").textContent,
  272. );
  273. };
  274. updateSnippet();
  275. </script>
  276. </body>
  277. </html>