-
-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
3 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { NextRequest } from 'next/server' | ||
|
||
import { NextServerResponse } from '~/lib/edge-function.server' | ||
import { getQueryClient } from '~/lib/query-client.server' | ||
|
||
const headers = { | ||
referer: `https://link.bilibili.com/p/center/index?visit_id=22ast2mb9zhc`, | ||
'User-Agent': `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Shiro`, | ||
} | ||
|
||
export const GET = async (req: NextRequest) => { | ||
const query = req.nextUrl.searchParams | ||
const cid = query.get('cid') | ||
const lang = query.get('lang') || 'zh' | ||
if (!cid) { | ||
return new NextServerResponse().status(400).end() | ||
} | ||
|
||
const queryClient = getQueryClient() | ||
const res = await queryClient.fetchQuery({ | ||
queryKey: ['xlog-summary', cid], | ||
queryFn: async () => { | ||
return fetch(`https://xlog.app/api/summary?cid=${cid}&lang=${lang}`, { | ||
headers: new Headers(headers), | ||
}) | ||
.then((res) => res.json()) | ||
.catch(() => null) | ||
}, | ||
}) | ||
|
||
const response = new NextServerResponse() | ||
if (!res) { | ||
return response.status(400).end() | ||
} | ||
|
||
return response.json({ ...res }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16b3866
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shiro – ./
innei.in
shiro-innei.vercel.app
springtide.vercel.app
shiro-git-main-innei.vercel.app