tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
29
pulls
pipelines
don't do auth redirects for feed routes
awarm.space
6 months ago
814df97f
bfebbcb5
+6
-1
1 changed file
expand all
collapse all
unified
split
middleware.ts
+6
-1
middleware.ts
···
41
41
42
42
let pub = routes?.publication_domains[0]?.publications;
43
43
if (pub) {
44
44
+
if (req.nextUrl.pathname.startsWith("/lish")) return;
44
45
let cookie = req.cookies.get("external_auth_token");
46
46
+
let isStaticReq =
47
47
+
req.nextUrl.pathname.includes("/rss") ||
48
48
+
req.nextUrl.pathname.includes("/atom") ||
49
49
+
req.nextUrl.pathname.includes("/json");
45
50
if (
51
51
+
!isStaticReq &&
46
52
(!cookie || req.nextUrl.searchParams.has("refreshAuth")) &&
47
53
!req.nextUrl.searchParams.has("auth_completed") &&
48
54
!hostname.includes("leaflet.pub")
···
50
56
return initiateAuthCallback(req);
51
57
}
52
58
let aturi = new AtUri(pub?.uri);
53
53
-
if (req.nextUrl.pathname.startsWith("/lish")) return;
54
59
return NextResponse.rewrite(
55
60
new URL(
56
61
`/lish/${aturi.host}/${encodeURIComponent(pub.name)}${req.nextUrl.pathname}`,