Skip to content

Commit 4cf783f

Browse files
committed
Add proxy
1 parent a971c12 commit 4cf783f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

web/pages/api/proxy-data.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default async function handler(req: any, res: any) {
2+
const { path } = req.query; // e.g. "v4FoTtuyX_XwjC3aS2_Y6/Martin.json"
3+
const upstreamUrl = `https://www.compassmeet.com/_next/data/${path}`;
4+
5+
const upstream = await fetch(upstreamUrl);
6+
const body = await upstream.text();
7+
8+
res.setHeader('Content-Type', 'application/json');
9+
res.setHeader('Access-Control-Allow-Origin', '*');
10+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
11+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
12+
13+
res.status(upstream.status).send(body);
14+
}

0 commit comments

Comments
 (0)