mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 08:09:11 +03:00
* fix(studio): jwt secret for self-hosted * update jwt secret variable name in postgrest config files * fix: add jwt secret to self hosted studio (#26859) * fix: add jwt secret to self hosted * chore: rename env var --------- Co-authored-by: Han Qiao <sweatybridge@gmail.com>
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import apiWrapper from 'lib/api/apiWrapper'
|
|
import { DEFAULT_PROJECT, PROJECT_ENDPOINT } from 'pages/api/constants'
|
|
|
|
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 handleGetAll(req, res)
|
|
default:
|
|
res.setHeader('Allow', ['GET'])
|
|
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
|
|
}
|
|
}
|
|
|
|
const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
// Platform specific endpoint
|
|
const response = {
|
|
project: {
|
|
...DEFAULT_PROJECT,
|
|
cloud_provider: 'AWS',
|
|
region: 'ap-southeast-1',
|
|
db_dns_name: '-',
|
|
db_host: 'localhost',
|
|
db_name: 'postgres',
|
|
db_port: 5432,
|
|
db_ssl: false,
|
|
db_user: 'postgres',
|
|
jwt_secret:
|
|
process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
|
|
},
|
|
services: [
|
|
{
|
|
id: 1,
|
|
name: 'Default API',
|
|
service_api_keys: [
|
|
{
|
|
api_key: process.env.SUPABASE_SERVICE_KEY,
|
|
api_key_encrypted: '-',
|
|
name: 'service_role key',
|
|
tags: 'service_role',
|
|
},
|
|
{
|
|
api_key: process.env.SUPABASE_ANON_KEY,
|
|
api_key_encrypted: '-',
|
|
name: 'anon key',
|
|
tags: 'anon',
|
|
},
|
|
],
|
|
app: { id: 1, name: 'Auto API' },
|
|
app_config: {
|
|
db_schema: 'public',
|
|
endpoint: PROJECT_ENDPOINT,
|
|
realtime_enabled: true,
|
|
},
|
|
},
|
|
],
|
|
}
|
|
|
|
return res.status(200).json(response)
|
|
}
|