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);
|
||||
|
||||
await fetch(`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`, {
|
||||
body: clonedRequest.body,
|
||||
headers: {
|
||||
"content-type": "application/x-sentry-envelope",
|
||||
"x-forwarded-for": context.request.headers.get(
|
||||
"cf-connecting-ip",
|
||||
) as string,
|
||||
const resp = await fetch(
|
||||
`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`,
|
||||
{
|
||||
body: clonedRequest.body,
|
||||
headers: {
|
||||
"content-type": "application/x-sentry-envelope",
|
||||
"x-forwarded-for": context.request.headers.get(
|
||||
"cf-connecting-ip",
|
||||
) as string,
|
||||
},
|
||||
method: "POST",
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
);
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
return new Response(await resp.text(), {
|
||||
headers: {
|
||||
"content-type": resp.headers.get("content-type") || "text/plain",
|
||||
},
|
||||
status: resp.status,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user