@@ -45,19 +45,22 @@ export async function GET(req: NextRequest) {
45
45
const now = Date . now ( )
46
46
47
47
// get tokens
48
- const tokensResponse = await fetch ( 'https://api.supabase.com/v1/oauth/token' , {
49
- method : 'POST' ,
50
- headers : {
51
- 'Content-Type' : 'application/x-www-form-urlencoded' ,
52
- Accept : 'application/json' ,
53
- Authorization : `Basic ${ btoa ( `${ process . env . NEXT_PUBLIC_SUPABASE_OAUTH_CLIENT_ID } :${ process . env . SUPABASE_OAUTH_SECRET } ` ) } ` ,
54
- } ,
55
- body : new URLSearchParams ( {
56
- grant_type : 'authorization_code' ,
57
- code,
58
- redirect_uri : req . nextUrl . origin + '/api/oauth/supabase/callback' ,
59
- } ) ,
60
- } )
48
+ const tokensResponse = await fetch (
49
+ `${ process . env . NEXT_PUBLIC_SUPABASE_PLATFORM_API_URL } /v1/oauth/token` ,
50
+ {
51
+ method : 'POST' ,
52
+ headers : {
53
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
54
+ Accept : 'application/json' ,
55
+ Authorization : `Basic ${ btoa ( `${ process . env . NEXT_PUBLIC_SUPABASE_OAUTH_CLIENT_ID } :${ process . env . SUPABASE_OAUTH_SECRET } ` ) } ` ,
56
+ } ,
57
+ body : new URLSearchParams ( {
58
+ grant_type : 'authorization_code' ,
59
+ code,
60
+ redirect_uri : req . nextUrl . origin + '/api/oauth/supabase/callback' ,
61
+ } ) ,
62
+ }
63
+ )
61
64
62
65
if ( ! tokensResponse . ok ) {
63
66
return new Response ( 'Failed to get tokens' , { status : 500 } )
@@ -71,13 +74,18 @@ export async function GET(req: NextRequest) {
71
74
token_type : 'Bearer'
72
75
}
73
76
74
- const organizationsResponse = await fetch ( 'https://api.supabase.com/v1/organizations' , {
75
- method : 'GET' ,
76
- headers : {
77
- Accept : 'application/json' ,
78
- Authorization : `Bearer ${ tokens . access_token } ` ,
79
- } ,
80
- } )
77
+ console . log ( { tokens } )
78
+
79
+ const organizationsResponse = await fetch (
80
+ `${ process . env . NEXT_PUBLIC_SUPABASE_PLATFORM_API_URL } /v1/organizations` ,
81
+ {
82
+ method : 'GET' ,
83
+ headers : {
84
+ Accept : 'application/json' ,
85
+ Authorization : `Bearer ${ tokens . access_token } ` ,
86
+ } ,
87
+ }
88
+ )
81
89
82
90
if ( ! organizationsResponse . ok ) {
83
91
return new Response ( 'Failed to get organizations' , { status : 500 } )
0 commit comments