Skip to content

Commit

Permalink
Update host url
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Feb 2, 2024
1 parent 733339d commit 0d9f0d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { kv } from "@vercel/kv";
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { Poll } from "./types";

const HOST_URL = "https://fc-frames-demo.vercel.app";
const HUB_URL = process.env["HUB_URL"] || "nemes.farcaster.xyz:2283";
const client = getSSLHubRpcClient(HUB_URL);

Expand Down Expand Up @@ -41,6 +40,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
console.error(err);
return res.status(500).end("Error initialize poll");
}
const hostUrl = `https://${req.headers.host}`;

if (req.method === "POST") {
let validatedMessage: Message | undefined = undefined;
Expand All @@ -53,7 +53,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(HOST_URL)) {
if (!urlString.startsWith(hostUrl)) {
return res.status(400).end(`Invalid frame url: ${urlBuffer}`);
}
} catch (err) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
return res.status(400).send(`Missing poll for #${pollId}`);
}

const imageUrl = `${HOST_URL}/api/image?id=${poll.id}&results=${voted ? "true" : "false"}&date=${Date.now()}${
const imageUrl = `${hostUrl}/api/image?id=${poll.id}&results=${voted ? "true" : "false"}&date=${Date.now()}${
fid > 0 ? `&fid=${fid}` : ""
}`;

Expand Down

0 comments on commit 0d9f0d7

Please sign in to comment.