diff --git a/server/api/s/[id].ts b/server/api/s/[id].ts index 991895f..c9eabd8 100644 --- a/server/api/s/[id].ts +++ b/server/api/s/[id].ts @@ -20,7 +20,7 @@ export default defineEventHandler(async (event): Promise => { const cacheTable = useCache() const now = Date.now() - if (process.env.NODE_ENV === "production" && cacheTable) { + if (cacheTable) { if (process.env.INIT_TABLE !== "false") await cacheTable.init() const cache = await cacheTable.get(id) if (cache) { diff --git a/server/hooks/useCache.ts b/server/hooks/useCache.ts index 2fce937..7ad8996 100644 --- a/server/hooks/useCache.ts +++ b/server/hooks/useCache.ts @@ -1,9 +1,10 @@ +import process from "node:process" import { Cache } from "#/database/cache" export function useCache() { try { const db = useDatabase() - if (db) return new Cache(db) + if (db && process.env.NODE_ENV === "production") return new Cache(db) } catch (e) { logger.error("failed to init database ", e) } diff --git a/server/middleware/auth.ts b/server/middleware/auth.ts index 6374b03..cb8a4e8 100644 --- a/server/middleware/auth.ts +++ b/server/middleware/auth.ts @@ -3,7 +3,6 @@ import { jwtVerify } from "jose" export default defineEventHandler(async (event) => { const url = getRequestURL(event) - console.log(url.pathname) if (["JWT_SECRET", "G_CLIENT_ID", "G_CLIENT_SECRET"].find(k => !process.env[k])) { event.context.disabledLogin = true if (url.pathname.startsWith("/api/me")) throw createError({ statusCode: 506, message: "Server not configured" })