Skip to content

Commit

Permalink
Merge pull request #943 from MuckRock/api-headers
Browse files Browse the repository at this point in the history
Add headers to tell the API who we are
  • Loading branch information
eyeseast authored Dec 4, 2024
2 parents c4d6034 + 1126df7 commit 6eee860
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ export async function handleFetch({ event, request, fetch }) {
if (request.url.startsWith(DC_BASE)) {
// handle docker issues
event.url.protocol = "https";

// pass through session cookie
request.headers.append("cookie", event.request.headers.get("cookie") ?? "");

// tell the API who we are
request.headers.append("x-forwarded-for", event.getClientAddress());
request.headers.set(
"x-bypass-rate-limit",
env.BYPASS_RATE_LIMIT_SECRET ?? "",
);
}

return fetch(request);
Expand Down

0 comments on commit 6eee860

Please sign in to comment.