Skip to content

Commit

Permalink
i18n(zh-cn): Update supabase.mdx (#8902)
Browse files Browse the repository at this point in the history
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
  • Loading branch information
Nin3lee and liruifengv committed Jul 23, 2024
1 parent 797d924 commit 91168a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/content/docs/zh-cn/guides/backend/supabase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Supabase 提供了开箱即用的身份验证功能。它支持电子邮件(
- `POST /api/auth/signin`: 用户登录。
- `GET /api/auth/signout`: 用户退出登录。

在新建目录 `src/pages/api/auth/` 下,创建与身份验证相关的三个端点:`signin.ts``signout.ts``register.ts`
在项目的 `src/pages/api/auth/` 目录下,创建这些端点。如果你正在使用 `hybrid` 渲染模式,则必须在每个文件的顶部指定 `export const prerender = false` 以按需渲染这些端点。你的项目现在应该包含这些新文件:

<FileTree title="Project Structure">
- src/
Expand All @@ -144,6 +144,8 @@ Supabase 提供了开箱即用的身份验证功能。它支持电子邮件(
`register.ts` 文件包含使用 Supabase 注册用户的代码逻辑。它接受带有一个电子邮箱和密码信息的 `POST` 请求。然后它将使用 Supabase SDK 创建一个新用户。

```ts title="src/pages/api/auth/register.ts"
// 使用 `output: 'hybrid'` 渲染模式时,需添加的配置:
// export const prerender = false;
import type { APIRoute } from "astro";
import { supabase } from "../../../lib/supabase";

Expand Down Expand Up @@ -172,6 +174,8 @@ export const POST: APIRoute = async ({ request, redirect }) => {
`signin.ts` 文件包含使用 Supabase 执行用户登录的代码逻辑。它接受一个带有电子邮箱和密码信息的 `POST` 请求。然后它将使用 Supabase SDK 登录用户。

```ts title="src/pages/api/auth/signin.ts"
// 使用 `output: 'hybrid'` 渲染模式时,需添加的配置:
// export const prerender = false;
import type { APIRoute } from "astro";
import { supabase } from "../../../lib/supabase";

Expand Down Expand Up @@ -207,6 +211,8 @@ export const POST: APIRoute = async ({ request, cookies, redirect }) => {
`signout.ts` 文件包含使用 Supabase 执行用户退出登录的代码逻辑。它接受一个 `GET` 请求并且删除用户的访问信息和刷新令牌。

```ts title="src/pages/api/auth/signout.ts"
// 使用 `output: 'hybrid'` 渲染模式时,需添加的配置:
// export const prerender = false;
import type { APIRoute } from "astro";

export const GET: APIRoute = async ({ cookies, redirect }) => {
Expand Down

0 comments on commit 91168a0

Please sign in to comment.