Skip to content

Commit

Permalink
fix(telemetry): proxy logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jul 25, 2024
1 parent 3ade0cb commit 6c660ec
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/telemetry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ export default {
console.log(request.headers.get('Origin'));
return new Response('Method Not Allowed', { status: 405 });
}
headers.set('Host', 'api-eu.mixpanel.com');
const res = await fetch(request, {
if (request.method === 'OPTIONS') {
return new Response(null, {
status: 204,
headers: {
'Access-Control-Allow-Origin': request.headers.get('Origin') ?? '*',
'Access-Control-Allow-Methods': 'POST, OPTIONS',
'Access-Control-Allow-Headers': '*',
},
});
}
headers.set('Host', 'api-js.mixpanel.com');
const url = new URL(request.url);
url.host = 'api-js.mixpanel.com';
const req = new Request(url, request);
const res = await fetch(req, {
headers,
});
return res;
Expand Down

0 comments on commit 6c660ec

Please sign in to comment.