tangled
alpha
login
or
join now
byarielm.fyi
/
atlast
16
fork
atom
ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork
atom
overview
issues
1
pulls
pipelines
oauth fix to separate netlify dev and --live mode
byarielm.fyi
4 months ago
ec722d45
0fa0a0df
1/1
deploy.yml
success
2s
+18
-5
1 changed file
expand all
collapse all
unified
split
netlify
functions
oauth-config.ts
+18
-5
netlify/functions/oauth-config.ts
···
1
1
export function getOAuthConfig() {
2
2
+
// Check if we have a public URL (production or --live mode)
3
3
+
const baseUrl = process.env.URL || process.env.DEPLOY_URL || process.env.DEPLOY_PRIME_URL;
4
4
+
2
5
// Development: loopback client for local dev
3
3
-
const isDev = process.env.NODE_ENV === 'development' || process.env.NETLIFY_DEV === 'true';
6
6
+
// Check if we're running on localhost (true local dev)
7
7
+
const isLocalhost = !baseUrl ||
8
8
+
baseUrl.includes('localhost') ||
9
9
+
baseUrl.includes('127.0.0.1') ||
10
10
+
baseUrl.startsWith('http://localhost') ||
11
11
+
baseUrl.startsWith('http://127.0.0.1');
12
12
+
13
13
+
// Use loopback for localhost, production for everything else
14
14
+
const isDev = isLocalhost;
4
15
5
16
if (isDev) {
6
17
const port = process.env.PORT || '8888';
···
10
21
['redirect_uri', `http://127.0.0.1:${port}/.netlify/functions/oauth-callback`],
11
22
['scope', 'atproto transition:generic'],
12
23
])}`;
24
24
+
25
25
+
console.log('Using loopback OAuth for local development');
26
26
+
console.log('Access your app at: http://127.0.0.1:' + port);
13
27
14
28
return {
15
29
clientId: clientId,
···
20
34
}
21
35
22
36
// Production: discoverable client logic
23
23
-
const baseUrl = process.env.URL || process.env.DEPLOY_PRIME_URL;
24
24
-
25
25
-
if (process.env.NETLIFY && !process.env.URL) {
26
26
-
throw new Error('process.env.URL is required in Netlify environment');
37
37
+
if (!baseUrl) {
38
38
+
throw new Error('No public URL available');
27
39
}
28
40
41
41
+
console.log('Using confidential OAuth client for production');
29
42
console.log('OAuth Config URLs:', {
30
43
DEPLOY_PRIME_URL: process.env.DEPLOY_PRIME_URL,
31
44
URL: process.env.URL,