+4
-1
src/app/api/series/[seriesId]/route.js
+4
-1
src/app/api/series/[seriesId]/route.js
···
6
6
export async function GET(req, ctx) {
7
7
const { seriesId } = await ctx.params
8
8
const { archive } = await req.nextUrl.searchParams
9
+
const domain = await req.nextUrl.hostname
10
+
const subdomain = domain.split(".").length > 1 ? domain.split(".")[0] : null
11
+
if (subdomain) setArchiveBaseUrl('https://'+subdomain)
9
12
if (archive) setArchiveBaseUrl(archive)
10
13
const series = await getSeries({seriesId: seriesId})
11
-
if (archive) resetArchiveBaseUrl()
14
+
if (archive || subdomain) resetArchiveBaseUrl()
12
15
return Response.json(series)
13
16
}
+5
-1
src/app/api/works/[workId]/chapters/[chapterId]/route.js
+5
-1
src/app/api/works/[workId]/chapters/[chapterId]/route.js
···
1
1
import { getWork } from "@fujocoded/ao3.js"
2
2
import { setArchiveBaseUrl, resetArchiveBaseUrl } from "@fujocoded/ao3.js/urls"
3
+
import siteMap from "@/lib/siteMap.js"
3
4
4
5
export const dynamic = 'force-static'
5
6
6
7
export async function GET(req, ctx) {
7
8
const { workId, chapterId } = await ctx.params
8
9
const params = await req.nextUrl.searchParams
10
+
const domain = await req.nextUrl.hostname
11
+
const subdomain = domain.split(".").length > 1 ? domain.split(".")[0] : null
9
12
const archive = params.get('archive')
13
+
if (subdomain) setArchiveBaseUrl('https://'+siteMap[subdomain])
10
14
if (archive) setArchiveBaseUrl(archive)
11
15
const work = await getWork({workId: workId, chapterId: chapterId})
12
-
if (archive) resetArchiveBaseUrl()
16
+
if (archive || subdomain) resetArchiveBaseUrl()
13
17
return Response.json(work)
14
18
}
+4
-1
src/app/api/works/[workId]/route.js
+4
-1
src/app/api/works/[workId]/route.js
···
4
4
export async function GET(req, ctx) {
5
5
const { workId } = await ctx.params
6
6
const params = await req.nextUrl.searchParams
7
+
const domain = await req.nextUrl.hostname
8
+
const subdomain = domain.split(".").length > 1 ? domain.split(".")[0] : null
7
9
const archive = params.get('archive')
10
+
if (subdomain) setArchiveBaseUrl('https://'+siteMap[subdomain])
8
11
if (archive) setArchiveBaseUrl(archive)
9
12
const work = await getWork({workId: workId})
10
-
if (archive) resetArchiveBaseUrl()
13
+
if (archive || subdomain) resetArchiveBaseUrl()
11
14
return Response.json(work)
12
15
}