Skip to content

Commit d9c22f3

Browse files
committed
feat(platforms): support marketplace cookie env
1 parent fc1e2d0 commit d9c22f3

4 files changed

Lines changed: 4 additions & 0 deletions

File tree

apps/api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const app = new Hono<{ Bindings: CloudflareBindings }>()
122122
try {
123123
raw = await p.fetch(id, {
124124
EMBED_USER_AGENT: c.env.EMBED_USER_AGENT,
125+
FACEBOOK_MARKETPLACE_COOKIE: c.env.FACEBOOK_MARKETPLACE_COOKIE,
125126
});
126127
} catch (cause) {
127128
const errorContext = getErrorContext(cause);

apps/api/worker-configuration.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface __BaseEnv_CloudflareBindings {
55
CACHE: KVNamespace;
66
AUTH_SECRET: string;
77
EMBED_USER_AGENT: string;
8+
FACEBOOK_MARKETPLACE_COOKIE?: string;
89
OTEL_ENDPOINT: string;
910
}
1011
declare namespace Cloudflare {

packages/platforms/src/platforms/facebook-marketplace.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const FacebookMarketplace: Platform<
2929
const response = await fetch(`https://www.facebook.com/marketplace/item/${id}/`, {
3030
headers: {
3131
"User-Agent": env?.EMBED_USER_AGENT ?? "",
32+
Cookie: env?.FACEBOOK_MARKETPLACE_COOKIE ?? "",
3233
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
3334
"Accept-Language": "en-US,en;q=0.9",
3435
"Sec-Fetch-Dest": "document",

packages/platforms/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface TransformOptions {
2929

3030
interface FetchEnv {
3131
EMBED_USER_AGENT: string;
32+
FACEBOOK_MARKETPLACE_COOKIE?: string;
3233
REDDIT_CLIENT_ID?: string;
3334
REDDIT_CLIENT_SECRET?: string;
3435
}

0 commit comments

Comments
 (0)