Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import type { FC } from "react";
import type { FC } from 'react';

type Props = {
historyData: {
id: number;
from: string;
to: string;
amount: number;
}[] | undefined
}
historyData:
| {
id: number;
from: string;
to: string;
amount: number;
}[]
| undefined;
};

const ReminderTest: FC<Props> = (props) => {
const discordWebhookUrl = "https://discord.com/api/webhooks/1430405385671671858/EZZlF3vrhVw-zwhBg9OVVuINsOJHSc-NneYRfVKzR-V32Ng76lYLcByOnVKCkNuVrIfG";
const discordWebhookUrl = '';
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting webhook URL to empty string will cause the fetch call to fail. The code attempts to fetch an invalid URL (''), which will throw an error when the button is clicked. Consider using environment variables to store the webhook URL securely (e.g., import.meta.env.VITE_DISCORD_WEBHOOK_URL), or add a check to disable the button or skip the fetch if the URL is not configured.

Copilot uses AI. Check for mistakes.

const onClick = () => {
if (confirm("Discordにリマインダが送信されます。よろしいですか?")) {
const message = props.historyData === undefined
? "No data"
: props.historyData.map((v) => `返金の流れ: ${v.to} -> ${v.from}\n\t金額: ${v.amount}\n`).join("\n");
if (confirm('Discordにリマインダが送信されます。よろしいですか?')) {
const message =
props.historyData === undefined
? 'No data'
: props.historyData.map((v) => `返金の流れ: ${v.to} -> ${v.from}\n\t金額: ${v.amount}\n`).join('\n');

fetch(discordWebhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: `==========\n@gangbujun_25033 \n現在残っている返金\n${message}` }),
});
}
};

return(
<button onClick={onClick}>リマインダーを送る</button>
)
return <button onClick={onClick}>リマインダーを送る</button>;
};

export default ReminderTest;
export default ReminderTest;
28 changes: 15 additions & 13 deletions products/notify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export interface Env {

export default {
async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext) {
const webhookUrl =
'https://discord.com/api/webhooks/1441344649863364608/vzOVqSEeNtjavKfq9MJaNoCB402dd_2W6J3BBr2nHFRngXEPaUm3r0IsvSs41ZIrSahz';
const webhookUrl = '';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Provide a valid webhook URL (empty string breaks workers)

When the scheduled worker runs, webhookUrl is now an empty string. In Cloudflare Workers, fetch requires an absolute URL, so fetch(webhookUrl, …) throws TypeError: Invalid URL and the scheduled task aborts before sending any reminders. If the goal is to remove the hard‑coded secret, this should be read from env (or the fetch should be skipped when the URL is empty) to avoid runtime failure.

Useful? React with 👍 / 👎.

Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting webhook URLs to empty strings will cause the fetch calls to fail. The code attempts to fetch an invalid URL (''), which will throw an error at runtime. Consider using environment variables to store webhook URLs securely (e.g., add WEBHOOK_URL to the Env interface and configure it in wrangler.jsonc), or add a check to skip the fetch call if the URL is not configured.

Copilot uses AI. Check for mistakes.

// DBのデータを取得
const data: string = await reminder(env.API_URL);
Expand All @@ -31,17 +30,20 @@ export default {
body: JSON.stringify({ content: data }),
});

const webhookUrlTest = 'https://discord.com/api/webhooks/1442164725273071649/SVu-eSyDZJ2pwXHOUFALlm0D8GtoeWS1oZzmJJan-H65Y9p3I3_Zmd4ysZL7vBo4vU-p';

const historyData = [{
to: "そぽたん",
from: "れん",
amount: 1000
}, {
to: "そぽたん",
from: "ひろと",
amount: 2000
}];
const webhookUrlTest = '';
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting webhookUrlTest to empty string will cause the fetch call to fail. The code attempts to fetch an invalid URL (''), which will throw an error at runtime. Consider using environment variables to store webhook URLs securely (e.g., add WEBHOOK_URL_TEST to the Env interface and configure it in wrangler.jsonc), or add a check to skip the fetch call if the URL is not configured.

Copilot uses AI. Check for mistakes.

const historyData = [
{
to: 'そぽたん',
from: 'れん',
amount: 1000,
},
{
to: 'そぽたん',
from: 'ひろと',
amount: 2000,
},
];

const message = historyData.map((v) => `返金の流れ: ${v.to} -> ${v.from}\n\t金額: ${v.amount}\n`).join('\n');

Expand Down
Loading