Skip to content

Commit

Permalink
Check
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Feb 2, 2024
1 parent 30eca30 commit 7a5eb2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
return res.status(500).end("Error initialize poll");
}
const hostUrl = `https://${req.headers.host}`;
return res.send(hostUrl);

if (req.method === "POST") {
let validatedMessage: Message | undefined = undefined;
Expand All @@ -55,6 +54,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
const urlBuffer = validatedMessage?.data?.frameActionBody?.url || [];
const urlString = Buffer.from(urlBuffer).toString("utf-8");
if (!urlString.startsWith(hostUrl)) {
console.warn(`Invalid frame url: ${urlBuffer} vs ${hostUrl}`);
return res.status(400).end(`Invalid frame url: ${urlBuffer}`);
}
} catch (err) {
Expand All @@ -79,6 +79,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {

const poll: Poll | null = await kv.hgetall(`poll:${pollId}`);
if (!poll) {
console.warn(`Missing poll for #${pollId}`);
return res.status(400).send(`Missing poll for #${pollId}`);
}

Expand Down

0 comments on commit 7a5eb2b

Please sign in to comment.