Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): jwt secret for self-hosted (#26858)

Alaister Young193ce3ba8d87
diff --git a/apps/studio/pages/api/config/postgrest.ts b/apps/studio/pages/api/config/postgrest.ts
new file mode 100644
index 00000000000..48e3da50dad
--- /dev/null
+++ b/apps/studio/pages/api/config/postgrest.ts
@@ -0,0 +1,31 @@
+import { components } from 'api-types'
+import apiWrapper from 'lib/api/apiWrapper'
+import { NextApiRequest, NextApiResponse } from 'next'
+
+export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
+
+async function handler(req: NextApiRequest, res: NextApiResponse) {
+ const { method } = req
+
+ switch (method) {
+ case 'GET':
+ return handleGet(req, res)
+ default:
+ res.setHeader('Allow', ['GET'])
+ res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
+ }
+}
+
+const handleGet = async (req: NextApiRequest, res: NextApiResponse) => {
+ const responseObj: components['schemas']['PostgrestConfigResponse'] = {
+ db_anon_role: 'anon',
+ db_extra_search_path: 'public',
+ db_schema: 'public, storage',
+ jwt_secret:
+ process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
+ max_rows: 100,
+ role_claim_key: '.role',
+ }
+
+ return res.status(200).json(responseObj)
+}
diff --git a/apps/studio/pages/api/projects/[ref]/config.ts b/apps/studio/pages/api/projects/[ref]/config.ts
index c38de492862..3984fefc5b9 100644
--- a/apps/studio/pages/api/projects/[ref]/config.ts
+++ b/apps/studio/pages/api/projects/[ref]/config.ts
@@ -23,7 +23,8 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
db_anon_role: 'anon',
db_extra_search_path: 'public',
db_schema: 'public, storage',
- jwt_secret: '-',
+ jwt_secret:
+ process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
max_rows: 100,
role_claim_key: '.role',
})
diff --git a/apps/studio/pages/api/props/project/[ref]/settings.ts b/apps/studio/pages/api/props/project/[ref]/settings.ts
index 20eebfda208..418b8f79a9c 100644
--- a/apps/studio/pages/api/props/project/[ref]/settings.ts
+++ b/apps/studio/pages/api/props/project/[ref]/settings.ts
@@ -30,7 +30,8 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
db_port: 5432,
db_ssl: false,
db_user: 'postgres',
- jwt_secret: '-',
+ jwt_secret:
+ process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
},
services: [
{
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index ea53888b5f3..b0ec5e18435 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -37,6 +37,7 @@ services:
SUPABASE_PUBLIC_URL: ${SUPABASE_PUBLIC_URL}
SUPABASE_ANON_KEY: ${ANON_KEY}
SUPABASE_SERVICE_KEY: ${SERVICE_ROLE_KEY}
+ AUTH_JWT_SECRET: ${JWT_SECRET}
LOGFLARE_API_KEY: ${LOGFLARE_API_KEY}
LOGFLARE_URL: http://analytics:4000