Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Steps component to captcha.mdx #8122

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/content/docs/en/recipes/captcha.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ description: Learn how to create an API route and fetch it from the client.
i18nReady: true
type: recipe
---
import { Steps } from '@astrojs/starlight/components';

[Server endpoints](/en/guides/endpoints/#server-endpoints-api-routes) can be used as REST API endpoints to run functions such as authentications, database access, and verifications without exposing sensitive data to the client.

In this recipe, an API route is used to verify Google reCAPTCHA v3 without exposing the secret to clients.

## Prerequisites

- A project with [SSR](/en/guides/server-side-rendering/) (`output: 'server'`) enabled

## Recipe

<Steps>
1. Create a `POST` endpoint that accepts recaptcha data, then verifies it with reCAPTCHA's API. Here, you can safely define secret values or read environment variables.

```js title="src/pages/recaptcha.js"
Expand Down Expand Up @@ -74,3 +77,4 @@ In this recipe, an API route is used to verify Google reCAPTCHA v3 without expos
</body>
</html>
```
</Steps>
Loading