The latest version of Shiro is compatible with LeetCode cards, but because LeetCode's API requires backend data retrieval, we use the cloud function of mx-space to bridge the request.
Why go around in circles and not directly fetch data on the server side for rendering? It seems that the logic for rendering Markdown is on the client side, so data retrieval also occurs on the client side, making it impossible to leverage the advantages of SSR.
Let's record this for easier migration later.
export default async function handler(ctx: Context) {
const requestBody = ctx.req.body
// General GraphQL request function
const response = await fetch('https://leetcode.cn/graphql/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});
if (!response.ok) {
throw new Error('Failed to fetch data from LeetCode API');
}
return await response.json();
}
Cloud function configuration information
This article is synchronized and updated to xLog by Mix Space. The original link is https://me.liuyaowen.cn/posts/codenotes/20241013