···
4
4
// Create auth context
5
5
export const AuthContext = createContext(null);
6
6
7
7
-
// Determine domain from environment variable or default
8
8
-
const domain = process.env.REACT_APP_CRED_BLUE_DOMAIN || 'https://cred.blue';
9
9
-
console.log(`(AuthProvider) Using domain: ${domain}`); // Log the domain being used
7
7
+
// Set the appropriate domain based on the current hostname
8
8
+
let domain = 'https://cred.blue';
10
9
11
11
-
// Construct metadata URL based on the domain
12
12
-
const metadataUrl = `${domain}/client-metadata.json`;
10
10
+
// Always use the current domain for client_id to ensure it matches the host
11
11
+
const metadataUrl = `https://cred.blue/client-metadata.json`;
13
12
14
14
-
// Client metadata for Bluesky OAuth - uses dynamic domain
13
13
+
// Client metadata for Bluesky OAuth
15
14
const clientMetadata = {
16
16
-
client_id: metadataUrl, // Use dynamically generated URL
17
17
-
client_name: "Cred.blue", // Keep name consistent or make dynamic if needed
18
18
-
client_uri: domain, // Use dynamic domain
19
19
-
redirect_uris: [`${domain}/login/callback`], // Use dynamic domain
20
20
-
logo_uri: `${domain}/favicon.ico`, // Use dynamic domain
15
15
+
client_id: metadataUrl,
16
16
+
client_name: "Cred.blue",
17
17
+
client_uri: domain,
18
18
+
redirect_uris: [`https://cred.blue/login/callback`],
19
19
+
logo_uri: `https://cred.blue/favicon.ico`,
21
20
scope: "atproto transition:generic",
22
21
grant_types: ["authorization_code", "refresh_token"],
23
22
response_types: ["code"],
···
45
44
try {
46
45
// Create the client instance
47
46
const oauthClient = new BrowserOAuthClient({
48
48
-
clientMetadata: clientMetadata, // Pass the dynamically configured metadata
47
47
+
clientMetadata: clientMetadata, // Reverted to original clientMetadata
49
48
handleResolver: 'https://public.api.bsky.app',
50
49
plcDirectoryUrl: 'https://plc.directory',
51
50
});