Supabase
The Open Source Firebase Alternative
Categories
Features
- 백엔드를 쉽게 만들기
- Postgres 기반에 Elixir를 이용한 실시간 DB엔진
- 웹소켓으로 변경을 실시간 반영
Architecture
- https://github.com/supabase/supabase/blob/master/i18n/README.ko.md
- PostgreSQL - PostgreSQL 은 30 년 이상 개발 · 개선되어왔다 객체 관계형 데이터베이스 시스템에서의 안정성, 기능의 안정성, 성능면에서 높은 평가를 얻고 있습니다.
- Realtime 은 웹 소켓을 사용하여 PostgreSQL 삽입, 업데이트 및 삭제를 수신 할 수있는 Elixir 서버입니다. Supabase는 Postgres의 내장 복제 기능을 수신하고 복제 바이트 스트림을 JSON으로 변환 한 다음 웹 소켓을 통해 JSON을 브로드 캐스트합니다.
- PostgREST - 는 PostgreSQL 데이터베이스를 RESTful API로 직접 변환하는 웹 서버입니다.
- Storage 는 Postgres를 사용하여 권한을 관리하여 S3에 저장된 파일을 관리하기위한 RESTful 인터페이스를 제공합니다.
- postgres-meta 는 Postgres를 관리하기위한 RESTful API로, 테이블을 가져오고, 역할을 추가하고, 쿼리를 실행할 수 있습니다.
- GoTrue 는 사용자 관리 및 SWT 토큰 발급을위한 SWT 기반 API입니다.
- Kong 은 클라우드 네이티브 API 게이트웨이입니다.
환경변수
- POSTGRES_URL
- POSTGRES_PRISMA_URL
- POSTGRES_URL_NON_POOLING
- POSTGRES_USER
- POSTGRES_HOST
- POSTGRES_PASSWORD
- POSTGRES_DATABASE
- SUPABASE_SERVICE_ROLE_KEY
- SUPABASE_ANON_KEY
- SUPABASE_URL
- NEXT_PUBLIC_SUPABASE_ANON_KEY
- NEXT_PUBLIC_SUPABASE_URL
varchar(n)를 기본적으로 사용하지 말아야 하는 이유
해당 행목 참조.
varchar(n) 대신 글자수 제한 방법
PostgreSQL:Constraints#글자 수 제한 항목 참조. 간단히:
Quickstart guide Nextjs with supabase
SQL Editor 에서 사용자 확인 가능:
프로젝트 생성:
npx create-next-app -e with-supabase my-app && cd my-app
## or
yarn create next-app -e with-supabase my-app && cd my-app
.env.local.example
파일을 .env.local
으로 바꾸고 다음 환경변수 확인:
- NEXT_PUBLIC_SUPABASE_URL
- NEXT_PUBLIC_SUPABASE_ANON_KEY
-
SUPABASE_SERVICE_ROLE_KEY- 이건 뭐지?
실행하고 확인하자.
Github 인증 연동
Github OAuth 페이지 참조.
Google 인증 연동
Configuration
To use the OAuth 2.0 flow, you will require the following information:
- Obtain OAuth credentials for your Google Cloud project in the Credentials page of the console. When creating a new credential, choose Web application. In Authorized redirect URIs enter
https://
<project-id>.supabase.co/auth/v1/callback
. This URL will be seen by your users, and you can customize it by configuring custom domains. - Configure the OAuth Consent Screen. This information is shown to the user when giving consent to your app. Within Authorized domains make sure you add your Supabase project's domain <project-id>
.supabase.co
. Configure the non-sensitive scopes by making sure the following ones are selected:.../auth/userinfo.email
,.../auth/userinfo.profile
,openid
. If you're selecting other sensitive scopes, your app may require additional verification. In those cases, it's best to use custom domains. - Finally, add the client ID and secret from step 1 in the Google provider on the Supabase Dashboard.
API Settings
프로젝트 셋팅 페이지로 들어가면 다음 항목이 있다.
- Exposed schemas
- 기본 값 - public, storage, graphql_public
- API에 노출할 스키마 목록. 이러한 스키마의 테이블, 뷰 및 저장 프로시저는 API 엔드포인트를 얻습니다. public 및 storage 는 기본적으로 보호됩니다. 즉, 변경 불가.
- Extra search path
- 기본 값 - public, extensions
- 모든 요청의 검색 경로에 추가할 추가 스키마입니다. 여러 스키마는 쉼표로 구분되어야 합니다.
- Max rows
- 기본 값 - 1000
- 뷰, 테이블 또는 저장 프로시저에서 반환되는 최대 행 수입니다. 우발적이거나 악의적인 요청에 대한 페이로드 크기를 제한합니다.
Self-Hosting with Docker
Learn how to configure and deploy Supabase with Docker.
Docker is the easiest way to get started with self-hosted Supabase. This guide assumes you are running the command from the machine you intend to host from.
Managing your secrets
Many components inside Supabase use secure secrets and passwords. These are listed in the self-hosting env file, but we strongly recommend using a secrets manager when deploying to production. Plain text files like dotenv lead to accidental costly leaks.
Some suggested systems include:
- Doppler
- Infisical
- Key Vault by Azure (Microsoft)
- Secrets Manager by AWS
- Secrets Manager by GCP
- Vault by Hashicorp
Architecture
Supabase is a combination of open source tools, each specifically chosen for Enterprise-readiness.
If the tools and communities already exist, with an MIT, Apache 2, or equivalent open license, we will use and support that tool. If the tool doesn't exist, we build and open source it ourselves.
- Kong is a cloud-native API gateway.
- GoTrue is an JWT based API for managing users and issuing JWT tokens.
- PostgREST is a web server that turns your PostgreSQL database directly into a RESTful API
- Realtime is an Elixir server that allows you to listen to PostgreSQL inserts, updates, and deletes using websockets. Realtime polls Postgres' built-in replication functionality for database changes, converts changes to JSON, then broadcasts the JSON over websockets to authorized clients.
- Storage provides a RESTful interface for managing Files stored in S3, using Postgres to manage permissions.
- postgres-meta is a RESTful API for managing your Postgres, allowing you to fetch tables, add roles, and run queries, etc.
- PostgreSQL is an object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
Configuring services
Each system has a number of configuration options which can be found in the relevant product documentation.
Troubleshooting
Multiple accounts with the same email address in the same linking domain detected: default
- error=server_error
- error_code=500
- error_description=Multiple accounts with the same email address in the same linking domain detected: default
사용하려는 OAuth 서비스 (나의 경우 github) 에 등록된 한 계정에 여러 이메일이 등록되어 있을 가능성이 있다.
한마디로 보조 메일을 supabase.auth 에 등록하지 말라.