diff --git a/apps/backend/src/routes/post.ts b/apps/backend/src/routes/post.ts index b1ffae9..aa3e0e5 100644 --- a/apps/backend/src/routes/post.ts +++ b/apps/backend/src/routes/post.ts @@ -68,11 +68,16 @@ async function sendDiscordNotification(payload: { tags: string[]; imageUrl?: string; }) { - const webhookUrl = config.discord.webhook; - if (!webhookUrl) return; + const webhookUrl = (config as any)?.webhook?.discord_webhook_uri + ?? (config as any)?.discord?.webhook; + + if (!webhookUrl || typeof webhookUrl !== "string") { + console.warn("[Discord Webhook] missing webhook URL in config.toml (expected [webhook].discord_webhook_uri)"); + return; + } try { - await fetch(webhookUrl, { + const response = await fetch(webhookUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ @@ -86,6 +91,11 @@ async function sendDiscordNotification(payload: { }], }), }); + + if (!response.ok) { + const errorText = await response.text().catch(() => ""); + console.error(`[Discord Webhook] failed status=${response.status} body=${errorText}`); + } } catch (error) { console.error("[Discord Webhook Error]", error); } @@ -565,4 +575,4 @@ export default new Elysia({ prefix: "/post" }) if (!randomPost) return status(404, "포스트를 찾을 수 없습니다."); return fetch(randomPost.mediaUrl, { cache: "no-store" }); - }); \ No newline at end of file + });