Send back response from sentry through tunnel
This commit is contained in:
@@ -12,18 +12,24 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
|
|
||||||
const sentryUrl = new URL(dsn);
|
const sentryUrl = new URL(dsn);
|
||||||
|
|
||||||
await fetch(`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`, {
|
const resp = await fetch(
|
||||||
body: clonedRequest.body,
|
`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`,
|
||||||
headers: {
|
{
|
||||||
"content-type": "application/x-sentry-envelope",
|
body: clonedRequest.body,
|
||||||
"x-forwarded-for": context.request.headers.get(
|
headers: {
|
||||||
"cf-connecting-ip",
|
"content-type": "application/x-sentry-envelope",
|
||||||
) as string,
|
"x-forwarded-for": context.request.headers.get(
|
||||||
|
"cf-connecting-ip",
|
||||||
|
) as string,
|
||||||
|
},
|
||||||
|
method: "POST",
|
||||||
},
|
},
|
||||||
method: "POST",
|
);
|
||||||
});
|
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(await resp.text(), {
|
||||||
status: 204,
|
headers: {
|
||||||
|
"content-type": resp.headers.get("content-type") || "text/plain",
|
||||||
|
},
|
||||||
|
status: resp.status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user