Skip to content

Latest commit

 

History

History
 
 

supabase-ory-cloud

Example using Ory Cloud and Supabase

Develop

Prerequisites

Create database & tables

  1. From your Supabase dashboard , click New project.
  2. Enter a Name for your Supabase project.
  3. Enter a secure Database Password.
  4. Select the Region you want.
  5. Click Create new project.
  6. Open table editor.
  7. Click on SQL editor on sidebar.
  8. Insert SQL table definition(see the code below)
  9. Click Run to create tables.
CREATE TABLE IF NOT EXISTS url (
	id SERIAL PRIMARY KEY,
	url VARCHAR(255) NOT NULL DEFAULT '',
	hash varchar(10) NOT NULL DEFAULT '',
	created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
	expired_at TIMESTAMP WITH TIME ZONE,
	owner_id VARCHAR(36) NOT NULL DEFAULT ''
);

CREATE UNIQUE INDEX idx_url_hash ON url(hash);

CREATE TABLE IF NOT EXISTS url_view (
	id SERIAL PRIMARY KEY,
	referer VARCHAR(255) NOT NULL DEFAULT '',
	url_id INT NOT NULL,
	CONSTRAINT fk_url_view FOREIGN KEY(url_id) REFERENCES url(id)
);

Run locally

Backend

Running ory proxy

   export ORY_SDK_URL=https://projectid.projects.oryapis.com
   ory proxy http://127.0.0.1:8090

Running the backend

   export SUPABASE_KEY=... # Please add your key
   export SUPABASE_URL=... # Please add your url
   export KRATOS_API_URL=http://127.0.0.1:4000/.ory
   export KRATOS_URL=http://127.0.0.1:4000/.ory/ui
   go run cmd/shorts/main.go

Frontend

   cd client
   npm i
   export KRATOS_API_URL=http://127.0.0.1:4000/.ory
   export KRATOS_URL=http://127.0.0.1:4000/.ory/ui
   export API_URL=http://127.0.0.1:4000
   npm run dev

Contribute

Feel free to open a discussion to provide feedback or talk about ideas, or open an issue if you want to add your example to the repository or encounter a bug. You can contribute to Ory in many ways, see the Ory Contributing Guidelines for more information.