···33// Configure this route as dynamic to fix static generation issues
44export const dynamic = 'force-dynamic';
5566-const DEFAULT_AUTH_SERVER = 'https://bsky.social';
66+const DEFAULT_AUTH_SERVER = 'https://public.api.bsky.app';
7788export async function POST(request: NextRequest) {
99 try {
···1212 let pdsEndpoint = body.pdsEndpoint || DEFAULT_AUTH_SERVER;
13131414 // CRITICAL FIX: Third-party PDS servers don't implement OAuth endpoints
1515- // Always use bsky.social for OAuth operations
1515+ // Always use public.api.bsky.app for OAuth operations
1616 let authServer = pdsEndpoint;
1717- if (!pdsEndpoint.includes('bsky.social')) {
1818- console.log('[NONCE API] Redirecting to bsky.social for OAuth on third-party PDS');
1717+ if (!pdsEndpoint.includes('public.api.bsky.app')) {
1818+ console.log('[NONCE API] Redirecting to public.api.bsky.app for OAuth on third-party PDS');
1919 authServer = DEFAULT_AUTH_SERVER;
2020 }
2121
+18-20
app/src/app/api/auth/token/route.ts
···33// Configure this route as dynamic to fix static generation issues
44export const dynamic = 'force-dynamic';
5566-const DEFAULT_AUTH_SERVER = 'https://bsky.social';
66+const DEFAULT_AUTH_SERVER = 'https://public.api.bsky.app';
77const REDIRECT_URI = 'https://flushes.app/auth/callback';
88const CLIENT_ID = 'https://flushes.app/client-metadata.json';
99···4141 });
42424343 // CRITICAL FIX: Use the correct token endpoint based on PDS type
4444- // - For bsky.network PDSes: always use bsky.social for token exchange
4545- // - For third-party PDSes: use their own endpoint for token exchange
4646- let authServer = pdsEndpoint || DEFAULT_AUTH_SERVER;
4444+ // - For bsky.network PDSes: always use public.api.bsky.app for token exchange
4545+ // - For bsky.social: use it directly
4646+ // - For third-party PDSes: use their own endpoint
4747+ let authServer = pdsEndpoint;
47484848- if (pdsEndpoint) {
4949- // If it's a bsky.network PDS, use bsky.social
5050- if (pdsEndpoint.includes('bsky.network')) {
5151- console.log(`[TOKEN ROUTE] Using bsky.social for bsky.network PDS: ${pdsEndpoint}`);
5252- authServer = DEFAULT_AUTH_SERVER;
5353- } else if (pdsEndpoint.includes('bsky.social')) {
5454- // Already using bsky.social
5555- console.log(`[TOKEN ROUTE] Using bsky.social endpoint directly`);
5656- } else {
5757- // For third-party PDSes, use their own endpoint for token exchange
5858- console.log(`[TOKEN ROUTE] Using third-party PDS's own endpoint for token exchange: ${pdsEndpoint}`);
5959- // Keep authServer as the original PDS endpoint
6060- }
4949+ // If it's a bsky.network PDS, use public.api.bsky.app
5050+ if (pdsEndpoint.includes('bsky.network')) {
5151+ console.log(`[TOKEN ROUTE] Using public.api.bsky.app for bsky.network PDS: ${pdsEndpoint}`);
5252+ authServer = DEFAULT_AUTH_SERVER;
5353+ } else if (pdsEndpoint.includes('public.api.bsky.app')) {
5454+ // Already using public.api.bsky.app
5555+ console.log(`[TOKEN ROUTE] Using public.api.bsky.app endpoint directly`);
6156 } else {
6262- // Default to bsky.social if no PDS endpoint provided
5757+ console.log(`[TOKEN ROUTE] Using third-party PDS's own endpoint for token exchange: ${pdsEndpoint}`);
5858+ }
5959+6060+ // Default to public.api.bsky.app if no PDS endpoint provided
6161+ if (!pdsEndpoint) {
6362 console.log(`[TOKEN ROUTE] No PDS endpoint provided, using default: ${DEFAULT_AUTH_SERVER}`);
6463 authServer = DEFAULT_AUTH_SERVER;
6564 }
···9493 code_verifier: codeVerifier
9594 });
96959797- // CRITICAL FIX: We only need to add cross-domain parameters when using bsky.social
9898- // for a third-party PDS's code exchange (which we're no longer doing)
9696+ // CRITICAL FIX: We only need to add cross-domain parameters when using public.api.bsky.app
9997 // But we'll keep this logic in case it's needed for specific PDS implementations
10098 if (originalPdsEndpoint && originalPdsEndpoint !== authServer) {
10199 console.log(`[TOKEN ROUTE] Cross-domain token exchange detected`);
+3-3
app/src/app/api/bluesky/feed/route.ts
···45454646// Bluesky agent for public interactions (used to resolve DIDs to handles if needed)
4747const agent = new BskyAgent({
4848- service: 'https://bsky.social'
4848+ service: 'https://public.api.bsky.app'
4949});
50505151export async function GET(request: NextRequest) {
···486486487487 // Create and filter mock entries
488488 const mockEntries: ProcessedEntry[] = [];
489489- const handles = ['alice.bsky.social', 'bob.bsky.social', 'charlie.bsky.social', 'dana.bsky.social'];
489489+ const handles = ['alice.public.api.bsky.app', 'bob.public.api.bsky.app', 'charlie.public.api.bsky.app', 'dana.public.api.bsky.app'];
490490 const emojis = ['🚽', '📱', '📚', '💩', '🧻', '💭', '😌'];
491491492492 for (let i = 0; i < 6; i++) {
···596596597597 // Create a new agent for this request
598598 const agent = new BskyAgent({
599599- service: 'https://bsky.social'
599599+ service: 'https://public.api.bsky.app'
600600 });
601601602602 // Log in with empty credentials (still required by the API)
+1-1
app/src/app/api/bluesky/flushing/route.ts
···55export const dynamic = 'force-dynamic';
6677// This is the default API URL, but we'll use the user's PDS endpoint instead if available
88-const DEFAULT_API_URL = 'https://bsky.social/xrpc';
88+const DEFAULT_API_URL = 'https://public.api.bsky.app/xrpc';
99const FLUSHING_STATUS_NSID = 'im.flushing.right.now';
10101111export async function POST(request: NextRequest) {
+3-3
app/src/app/api/bluesky/profile/route.ts
···222222 }
223223224224 // Step 2: Get the PDS service endpoint from PLC directory
225225- let serviceEndpoint = 'https://bsky.social'; // Start with bsky.social as fallback
225225+ let serviceEndpoint = 'https://public.api.bsky.app'; // Start with public.api.bsky.app as fallback
226226 let servicePds: string | null = null; // Store the actual PDS domain for logging
227227 try {
228228 console.log(`Looking up PDS endpoint for DID: ${did}`);
···468468 }
469469470470 // 2. For third-party domain handles, try using the handle's domain
471471- if (handle.includes('.') && !handle.endsWith('bsky.social') && !handle.endsWith('flushes.app') && !handle.endsWith('flushing.im')) {
471471+ if (handle.includes('.') && !handle.endsWith('public.api.bsky.app') && !handle.endsWith('flushes.app') && !handle.endsWith('flushing.im')) {
472472 const domain = handle.split('.').slice(1).join('.');
473473 try {
474474 console.log(`Trying handle domain access: https://${domain}`);
···915915916916 // IMPORTANT: For third-party PDS users, we need to use the handle from describeRepo
917917 // which will be accurate for their PDS, rather than the handle we resolved earlier
918918- if (pdsEndpoint && pdsEndpoint !== 'https://bsky.social' && pdsEndpoint !== 'https://public.api.bsky.app' && data.handle) {
918918+ if (pdsEndpoint && pdsEndpoint !== 'https://public.api.bsky.app' && data.handle) {
919919 console.log(`Using handle from PDS response: ${data.handle} instead of ${userHandle}`);
920920 userHandle = data.handle;
921921 }
+1-1
app/src/app/api/bluesky/search/route.ts
···1515 }
16161717 // Make a direct fetch request to the Bluesky API endpoint
1818- const apiUrl = `https://bsky.social/xrpc/app.bsky.actor.searchActorsTypeahead?q=${encodeURIComponent(term)}&limit=5`;
1818+ const apiUrl = `https://public.api.bsky.app/xrpc/app.bsky.actor.searchActorsTypeahead?q=${encodeURIComponent(term)}&limit=5`;
19192020 console.log('Fetching from API:', apiUrl);
2121
···11import { exportJWK, generateDPoPToken } from './bluesky-auth';
2233// Bluesky API utilities
44-const DEFAULT_API_URL = 'https://bsky.social/xrpc';
44+const DEFAULT_API_URL = 'https://public.api.bsky.app/xrpc';
5566// Create a custom lexicon schema for "im.flushing.right.now"
77// This would normally be registered with the AT Protocol
···7676 // CRITICAL FIX: Token refresh endpoint selection based on PDS type
7777 let authServer = pdsEndpoint;
78787979- // For bsky.network PDSes, use bsky.social
7979+ // For bsky.network PDSes, use public.api.bsky.app
8080 if (pdsEndpoint.includes('bsky.network')) {
8181- console.log('[TOKEN REFRESH] Using bsky.social for bsky.network PDS');
8282- authServer = 'https://bsky.social';
8383- } else if (pdsEndpoint.includes('bsky.social')) {
8484- // Already using bsky.social
8585- console.log('[TOKEN REFRESH] Using bsky.social directly');
8181+ console.log('[TOKEN REFRESH] Using public.api.bsky.app for bsky.network PDS');
8282+ authServer = 'https://public.api.bsky.app';
8383+ } else if (pdsEndpoint.includes('public.api.bsky.app')) {
8484+ // Already using public.api.bsky.app
8585+ console.log('[TOKEN REFRESH] Using public.api.bsky.app directly');
8686 } else {
8787 // For third-party PDSes, use their own endpoint for token refresh
8888 console.log('[TOKEN REFRESH] Using third-party PDS\'s own endpoint for token refresh:', pdsEndpoint);
···9797 let dpopNonce = null;
98989999 // Special handling for third-party PDS token refresh
100100- if (!authServer.includes('bsky.social') && !authServer.includes('bsky.network')) {
100100+ if (!authServer.includes('public.api.bsky.app') && !authServer.includes('bsky.network')) {
101101 try {
102102 // For third-party PDS, use a two-step approach to get the valid nonce:
103103 console.log('[TOKEN REFRESH] Direct nonce retrieval from third-party PDS');
···382382 let authServer = pdsEndpoint;
383383384384 // Special case for token refresh only (not normal API calls)
385385- // Only bsky.network PDSes should redirect to bsky.social
386386- if (pdsEndpoint && pdsEndpoint.includes('bsky.network')) {
387387- console.log('[AUTH CHECK] Will use bsky.social for OAuth on bsky.network PDS');
388388- authServer = 'https://bsky.social';
385385+ // Only bsky.network PDSes should redirect to public.api.bsky.app
386386+ if (pdsEndpoint.includes('bsky.network')) {
387387+ console.log('[AUTH CHECK] Will use public.api.bsky.app for OAuth on bsky.network PDS');
388388+ authServer = 'https://public.api.bsky.app';
389389 } else {
390390 console.log('[AUTH CHECK] Using the actual PDS endpoint for auth:', pdsEndpoint);
391391 }
···499499 // Follow the same server selection logic as in refreshAccessToken
500500 let refreshAuthServer = pdsEndpoint;
501501502502- // For bsky.network PDSes, use bsky.social
502502+ // For bsky.network PDSes, use public.api.bsky.app
503503 if (pdsEndpoint.includes('bsky.network')) {
504504- console.log('[AUTH CHECK] Will use bsky.social for bsky.network PDS');
505505- refreshAuthServer = 'https://bsky.social';
506506- } else if (pdsEndpoint.includes('bsky.social')) {
507507- // Already using bsky.social
508508- console.log('[AUTH CHECK] Will use bsky.social directly');
504504+ console.log('[AUTH CHECK] Will use public.api.bsky.app for bsky.network PDS');
505505+ refreshAuthServer = 'https://public.api.bsky.app';
506506+ } else if (pdsEndpoint.includes('public.api.bsky.app')) {
507507+ // Already using public.api.bsky.app
508508+ console.log('[AUTH CHECK] Will use public.api.bsky.app directly');
509509 } else {
510510 // For third-party PDSes, use their own endpoint
511511 console.log('[AUTH CHECK] Will use third-party PDS\'s own endpoint:', pdsEndpoint);
···703703 const publicKey = await exportJWK(keyPair.publicKey);
704704705705 // Use the PDS endpoint if available
706706- const baseUrl = pdsEndpoint ? `${pdsEndpoint}/xrpc` : 'https://bsky.social/xrpc';
706706+ const baseUrl = pdsEndpoint ? `${pdsEndpoint}/xrpc` : 'https://public.api.bsky.app/xrpc';
707707708708 // Step 1: If we have a DID, we want to get both the user's DID and handle
709709 let endpoint;
···835835836836 console.log(`Using PDS endpoint for create record: ${pdsEndpoint}`);
837837838838- const baseUrl = pdsEndpoint ? `${pdsEndpoint}/xrpc` : 'https://bsky.social/xrpc';
838838+ const baseUrl = pdsEndpoint ? `${pdsEndpoint}/xrpc` : 'https://public.api.bsky.app/xrpc';
839839 const endpoint = `${baseUrl}/com.atproto.repo.createRecord`;
840840841841 console.log(`Endpoint for create record: ${endpoint}`);
+1-1
app/src/lib/bluesky-auth.ts
···11// Default Bluesky OAuth client configuration
22-const DEFAULT_AUTH_SERVER = 'https://bsky.social';
22+const DEFAULT_AUTH_SERVER = 'https://public.api.bsky.app';
33const REDIRECT_URI = 'https://flushes.app/auth/callback';
44const CLIENT_ID = 'https://flushes.app/client-metadata.json';
55// Need to include transition:generic to be able to create records
+1-1
app/src/lib/oauth-client.ts
···3030 if (!_oauthClient) {
3131 _oauthClient = new BrowserOAuthClient({
3232 clientMetadata: CLIENT_METADATA as any,
3333- handleResolver: 'https://bsky.social',
3333+ handleResolver: 'https://public.api.bsky.app',
3434 responseMode: 'fragment'
3535 })
3636 }