Skip to content

Commit

Permalink
feat: Throttle update for proxy (#3968)
Browse files Browse the repository at this point in the history
* fix: proxy updates

* feat: modifying adapters to forward ip properly

* fix: adjusting for hosted env

* fix: updates after testing with next proxy

* fix: clean up
  • Loading branch information
YazeedLoonat committed Mar 20, 2024
1 parent b5f2c8d commit bc759c2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/guards/throttler.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ThrottleGuard extends ThrottlerGuard {
protected async getTracker(req: Record<string, any>): Promise<string> {
if (req?.headers && req.headers['x-forwarded-for']) {
// if we are passing through the proxy use forwarded for
return req.headers['x-forwarded-for'];
return req.headers['x-forwarded-for'].split(',')[0];
}
return req.ips.length ? req.ips[0] : req.ip;
}
Expand Down
1 change: 1 addition & 0 deletions sites/partners/src/pages/api/adapter/[...backendUrl].ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
jurisdictionName: req.headers.jurisdictionname,
language: req.headers.language,
appUrl: req.headers.appurl,
"x-forwarded-for": req.headers["x-forwarded-for"] || "",
},
paramsSerializer: (params) => {
return qs.stringify(params)
Expand Down
1 change: 1 addition & 0 deletions sites/public/src/pages/api/adapter/[...backendUrl].ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
jurisdictionName: req.headers.jurisdictionname,
language: req.headers.language,
appUrl: req.headers.appurl,
"x-forwarded-for": req.headers["x-forwarded-for"] || "",
},
paramsSerializer: (params) => {
return qs.stringify(params)
Expand Down

0 comments on commit bc759c2

Please sign in to comment.