a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

properly reroute the pub to custom domains

+13 -4
+13 -4
middleware.ts
··· 26 26 if (req.nextUrl.pathname === "/not-found") return; 27 27 let { data: routes } = await supabase 28 28 .from("custom_domains") 29 - .select("*, custom_domain_routes(*), publication_domains(*)") 29 + .select( 30 + "*, custom_domain_routes(*), publication_domains(*, publications(*))", 31 + ) 30 32 .eq("domain", hostname) 31 33 .single(); 32 - if (routes?.publication_domains[0]) { 33 - let aturi = new AtUri(routes.publication_domains[0].publication); 34 - return NextResponse.rewrite(new URL(`/lish/${aturi.host}`, req.url)); 34 + 35 + let pub = routes?.publication_domains[0]?.publications; 36 + if (pub) { 37 + let aturi = new AtUri(pub?.uri); 38 + return NextResponse.rewrite( 39 + new URL( 40 + `/lish/${aturi.host}/${pub.name}${req.nextUrl.pathname}`, 41 + req.url, 42 + ), 43 + ); 35 44 } 36 45 if (routes) { 37 46 let route = routes.custom_domain_routes.find(