supabase

框架

supabase/supabase

开源 Firebase 替代品,提供 Postgres 数据库、认证、API 和实时功能。

项目简介

Supabase 是一个托管式 Postgres 开发平台,集成了认证、自动生成的 REST 和 GraphQL API、实时订阅、文件存储以及 AI/向量工具。基于企业级开源工具构建,提供类似 Firebase 的开发者体验。

README 预览

\n\n\n\n\n# Supabase\n\n[Supabase](https://supabase.com) is the Postgres development platform. We're building the features of Firebase using enterprise-grade open source tools.\n\n- [x] Hosted Postgres Database. [Docs](https://supabase.com/docs/guides/database)\n- [x] Authentication and Authorization. [Docs](https://supabase.com/docs/guides/auth)\n- [x] Auto-generated APIs.\n  - [x] REST. [Docs](https://supabase.com/docs/guides/api)\n  - [x] GraphQL. [Docs](https://supabase.com/docs/guides/graphql)\n  - [x] Realtime subscriptions. [Docs](https://supabase.com/docs/guides/realtime)\n- [x] Functions.\n  - [x] Database Functions. [Docs](https://supabase.com/docs/guides/database/functions)\n  - [x] Edge Functions [Docs](https://supabase.com/docs/guides/functions)\n- [x] File Storage. [Docs](https://supabase.com/docs/guides/storage)\n- [x] AI + Vector/Embeddings Toolkit. [Docs](https://supabase.com/docs/guides/ai)\n- [x] Dashboard\n\n\n\nWatch "releases" of this repo to get notified of major updates.\n\n\n\n## Documentation\n\nFor full documentation, visit [supabase.com/docs](https://supabase.com/docs)\n\nTo see how to Contribute, visit [Getting Started](./DEVELOPERS.md)\n\n## Community & Support\n\n- [Community Forum](https://github.com/supabase/supabase/discussions). Best for: help with building, discussion about database best practices.\n- [GitHub Issues](https://github.com/supabase/supabase/issues). Best for: bugs and errors you encounter using Supabase.\n- [Email Support](https://supabase.com/docs/support#business-support). Best for: problems with your database or infrastructure.\n- [Discord](https://discord.supabase.com). Best for: sharing your applications and hanging out with the community.\n\n## How it works\n\nSupabase is a combination of open source tools. We’re building the features of Firebase using enterprise-grade, open source products. If the tools and communities exist, with an MIT, Apache 2, or equivalent open license, we will use and support that tool. 

常见问题 (5)

故障排除
为什么 Supabase 存储上传的内容包含 multipart 边界而不是实际的文件内容?

当您在 file_options 中传递大写的 Content-Type 请求头时,就会出现这种情况。存储后端无法解析 multipart 请求体,会将整个封装内容(包括 --boundary 字符串)作为文件内容存储,同时仍然返回 200 OK。

**修复方法:** 改用小写的 content-type 请求头:

# ❌ 有问题 - 会存储 multipart 边界
supabase.storage.from_("bucket").upload(
    filename, file_content,
    file_options={"Content-Type": file.content_type}
)

# ✅ 正常 - 存储实际的文件字节
supabase.storage.from_("bucket").upload(
    filename, file_content,
    file_options={"content-type": file.content_type}
)

此问题同时影响 Python 客户端(已在 v2.17.0 上确认)和直接的 REST API 调用。尽管根据 RFC 规范 HTTP 请求头应当不区分大小写,但存储后端的 multipart 解析器是区分大小写的。如果您已经上传了损坏的文件,请使用小写请求头重新上传,并验证下载返回的内容是否有效。

来源 Issue #37315
故障排除
为什么在调用 supabase.auth.oauth.approveAuthorization() 之后,window.location.href 会变成 undefined?

supabase.auth.oauth.approveAuthorization() / denyAuthorization() 的响应返回的是 data.redirect_url,而不是 data.redirect_to。旧版 Supabase 文档中的示例使用了错误的属性名,导致 window.location.href = undefined,并造成无限重定向循环至 /oauth/undefined。修复方法:使用 const { data, error } = await supabase.auth.oauth.approveAuthorization(authorizationId),然后执行 window.location.href = data.redirect_url。注意:在浏览器中,SDK 默认会自动重定向,因此只有在传入 skipBrowserRedirect: true 时才需要手动重定向。该文档现已更正。

来源 Issue #45006
故障排除
为什么在 Supabase 中禁用电子邮件确认后,我仍然收到 "Email Not Confirmed" 错误?

“Enable email confirmations”开关(Authentication > Providers > Email)仅适用于新注册用户。在启用确认功能期间注册的用户仍处于未确认状态,并且仍会遇到“Email Not Confirmed”错误。要解决现有用户的问题,可以:1)通过 SQL Editor 手动确认:UPDATE auth.users SET email_confirmed_at = NOW() WHERE email_confirmed_at IS NULL;(或使用 WHERE email = 'user@example.com' 指定特定用户),或者 2)在 Authentication > Users 中删除测试用户并重新注册。禁用该设置后,新注册的用户将被自动确认,并可立即登录。

来源 Issue #5113
故障排除
如何恢复意外删除的 Supabase 项目?

立即通过 support@supabase.com 联系 Supabase 支持团队,并提供你的项目 ref、所属组织和删除日期,以便他们审查你的具体情况。请注意,根据 Supabase 的文档,已删除的项目通常会被永久移除,无法自行恢复,因此不保证能够找回。为防止将来再次发生类似情况:在 Project Settings > Database > Backups 下启用每日备份(Pro 计划提供此功能),定期下载备份,或者使用 pg_dump 通过 Project Settings > Database 中的连接字符串自行创建转储。

来源 Issue #51595
故障排除
为什么在支付 Supabase 账单时,我的信用卡或借记卡会被拒绝?

如果在支付 Supabase 账单时您的卡片被拒绝,请先与您的银行或发卡机构确认他们并未阻止该交易。如果银行确认卡片没有问题,但多张卡片仍然付款失败,则这是账单端的问题,无法在您这边解决。请直接通过 support@supabase.com 联系 Supabase 账单支持团队,并提供您的组织/项目详细信息,以便团队调查付款失败的原因并处理您的账单。

来源 Issue #51887