feat: Re-enable Anilist response caching and configure proxy URL via environment variable.

This commit is contained in:
2025-11-28 17:00:18 +08:00
parent bd958fb1ab
commit a25111acbf
2 changed files with 8 additions and 7 deletions

View File

@@ -43,11 +43,11 @@ export class AnilistDurableObject extends DurableObject {
const { variables } = body;
const storageKey = variables.id;
const cache = await this.state.storage.get(storageKey);
// if (cache) {
// return new Response(JSON.stringify(cache), {
// headers: { "Content-Type": "application/json" },
// });
// }
if (cache) {
return new Response(JSON.stringify(cache), {
headers: { "Content-Type": "application/json" },
});
}
const anilistResponse = await this.fetchTitleFromAnilist(
variables.id,
@@ -95,7 +95,7 @@ export class AnilistDurableObject extends DurableObject {
headers["Authorization"] = `Bearer ${token}`;
}
const response = await fetch("http://localhost:3000/proxy", {
const response = await fetch(`${env.PROXY_URL}/proxy`, {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,5 +1,5 @@
/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: 55b6bc5eef0b3709210a3c57164a6bda)
// Generated by Wrangler by running `wrangler types` (hash: 3b0ff08dc5a1a73091e35f975f87bee1)
// Runtime types generated with workerd@1.20251011.0 2024-09-23 nodejs_compat
declare namespace Cloudflare {
interface GlobalProps {
@@ -15,6 +15,7 @@ declare namespace Cloudflare {
CLOUDFLARE_D1_TOKEN: string;
CLOUDFLARE_ACCOUNT_ID: string;
CLOUDFLARE_DATABASE_ID: string;
PROXY_URL: string;
ANILIST_DO: DurableObjectNamespace<import("./src/index").AnilistDo>;
DB: D1Database;
ANILIST_UPDATES: Queue;