Skip to content

feat: add serverless trade meta rendering#213

Open
TomasCImach wants to merge 8 commits intomainfrom
codex/implement-ssr-with-meta-tags-for-trade-routes
Open

feat: add serverless trade meta rendering#213
TomasCImach wants to merge 8 commits intomainfrom
codex/implement-ssr-with-meta-tags-for-trade-routes

Conversation

@TomasCImach
Copy link
Copy Markdown
Member

Summary

  • add serverless function to inject OG meta tags per trade market
  • generate market meta (title, description, image) during rendering
  • configure Vercel bot protection to allow Twitterbot

Testing

  • pnpm lint (fails: Unexpected any, no-extra-semi, etc.)
  • pnpm build

https://chatgpt.com/codex/tasks/task_e_68bae0198988832e9251100936b9aa11

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
overlay-interface-v2 Ready Ready Preview Comment Sep 5, 2025 5:22pm

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 5, 2025

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `botProtection`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment thread api/trade.ts
Comment on lines +17 to +22
const query = (req as any).query || {};
const market = typeof query.market === 'string' ? (query.market as string) : undefined;
const { title, description, image } = getMarketMeta(market);

const headTags = `\n <meta property="og:title" content="${title}" />\n <meta property="og:image" content="${image}" />\n <meta name="description" content="${description}" />\n <meta property="og:description" content="${description}" />\n `;

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] Escape market query before injecting meta tags

The handler writes the market query string directly into the OG title/description meta tags without any escaping, so a crafted URL like /trade?market=%22%3E<script>alert(1)</script> will inject arbitrary HTML/JS into the returned page head. That exposes both users and crawlers that fetch the URL to XSS. The values should be sanitized or restricted to a whitelist before interpolating them into the HTML.

Useful? React with 👍 / 👎.

Comment thread src/utils/getMarketMeta.ts Outdated
Comment on lines +1 to +13
import { DEFAULT_LOGO, MARKETS_FULL_LOGOS } from "../constants/markets";

export interface MarketMeta {
title: string;
description: string;
image: string;
}

export function getMarketMeta(encodedMarket?: string): MarketMeta {
const marketKey = encodedMarket ?? "";
const title = marketKey ? decodeURIComponent(marketKey) : "Overlay Markets";
const image = MARKETS_FULL_LOGOS[marketKey] ?? DEFAULT_LOGO;
const description = `Trade ${title} on Overlay Markets`;
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] API bundles front‑end image modules into Node function

The serverless /trade endpoint pulls getMarketMeta, which imports MARKETS_FULL_LOGOS that in turn imports numerous .webp assets via Vite loaders. Vercel’s Node builder does not understand image module imports, so bundling the function will fail with an unknown file extension error and the endpoint won’t respond. Server code should reference plain URLs or move the mapping to JSON rather than importing client-only asset modules.

Useful? React with 👍 / 👎.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 5, 2025

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: `functions.api/trade.ts.includeFiles` should be string

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant