···
4
4
// Create auth context
5
5
export const AuthContext = createContext(null);
6
6
7
7
-
// Determine environment
8
8
-
const isDevelopment = process.env.NODE_ENV === 'development';
9
9
-
const hostname = window.location.hostname;
10
10
-
11
7
// Set the appropriate domain based on the current hostname
12
12
-
let domain;
13
13
-
if (isDevelopment) {
14
14
-
domain = 'http://localhost:3000';
15
15
-
} else if (hostname === 'testing.cred.blue') {
16
16
-
domain = 'https://testing.cred.blue';
17
17
-
} else {
18
18
-
domain = 'https://cred.blue';
19
19
-
}
8
8
+
let domain = 'https://testing.cred.blue';
20
9
21
21
-
// Use the production client metadata URL for all environments
22
22
-
// This ensures we don't need separate metadata files
23
23
-
const metadataUrl = 'https://cred.blue/client-metadata.json';
10
10
+
// Always use the current domain for client_id to ensure it matches the host
11
11
+
const metadataUrl = `https://testing.cred.blue/client-metadata.json`;
24
12
25
13
// Client metadata for Bluesky OAuth
26
14
const clientMetadata = {
27
15
client_id: metadataUrl,
28
16
client_name: "Cred.blue",
29
17
client_uri: domain,
30
30
-
redirect_uris: [`${domain}/login/callback`],
31
31
-
logo_uri: `${domain}/favicon.ico`,
18
18
+
redirect_uris: [`https://testing.cred.blue/login/callback`],
19
19
+
logo_uri: `https://testing.cred.blue/favicon.ico`,
32
20
scope: "atproto",
33
21
grant_types: ["authorization_code", "refresh_token"],
34
22
response_types: ["code"],
···
47
35
useEffect(() => {
48
36
const initializeAuth = async () => {
49
37
try {
50
50
-
// Create the OAuth client
38
38
+
// Create the OAuth client with inline metadata
51
39
const oauthClient = new BrowserOAuthClient({
52
52
-
clientMetadata,
40
40
+
clientMetadata, // Pass the inline metadata directly
53
41
handleResolver: 'https://bsky.social', // Using bsky.social as handle resolver
54
42
});
55
43