Add user tagging for logged-in staff users
This commit is contained in:
23
functions/api/st.ts
Normal file
23
functions/api/st.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { jsonError } from "../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const dsn = context.request.headers.get("dsn");
|
||||
|
||||
if (!dsn || dsn !== context.env.DSN) return jsonError("Bad or no DSN", 400);
|
||||
|
||||
const sentryUrl = new URL(dsn);
|
||||
await fetch(`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`, {
|
||||
body: context.request.body,
|
||||
headers: {
|
||||
"content-type": "application/x-sentry-envelope",
|
||||
"x-forwarded-for": context.request.headers.get(
|
||||
"cf-connecting-ip",
|
||||
) as string,
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user