a tool for shared writing and social publishing

fix uri redirect route

+14 -6
+14 -6
app/lish/uri/[uri]/route.ts
··· 9 9 */ 10 10 export async function GET( 11 11 request: NextRequest, 12 - { params }: { params: Promise<{ uri: string }> } 12 + { params }: { params: Promise<{ uri: string }> }, 13 13 ) { 14 14 try { 15 15 const { uri: uriParam } = await params; ··· 32 32 const basePath = record.base_path; 33 33 34 34 if (!basePath) { 35 - return new NextResponse("Publication has no base_path", { status: 404 }); 35 + return new NextResponse("Publication has no base_path", { 36 + status: 404, 37 + }); 36 38 } 37 39 38 40 // Redirect to the publication's hosted domain (temporary redirect since base_path can change) ··· 47 49 48 50 if (docInPub?.publication && docInPub.publications) { 49 51 // Document is in a publication - redirect to domain/rkey 50 - const record = docInPub.publications.record as PubLeafletPublication.Record; 52 + const record = docInPub.publications 53 + .record as PubLeafletPublication.Record; 51 54 const basePath = record.base_path; 52 55 53 56 if (!basePath) { 54 - return new NextResponse("Publication has no base_path", { status: 404 }); 57 + return new NextResponse("Publication has no base_path", { 58 + status: 404, 59 + }); 55 60 } 56 61 57 62 // Ensure basePath ends without trailing slash ··· 60 65 : basePath; 61 66 62 67 // Redirect to the document on the publication's domain (temporary redirect since base_path can change) 63 - return NextResponse.redirect(`${cleanBasePath}/${uri.rkey}`, 307); 68 + return NextResponse.redirect( 69 + `https://${cleanBasePath}/${uri.rkey}`, 70 + 307, 71 + ); 64 72 } 65 73 66 74 // If not in a publication, check if it's a standalone document ··· 74 82 // Standalone document - redirect to /p/did/rkey (temporary redirect) 75 83 return NextResponse.redirect( 76 84 new URL(`/p/${uri.host}/${uri.rkey}`, request.url), 77 - 307 85 + 307, 78 86 ); 79 87 } 80 88