Skip to content

Commit

Permalink
feat: grab client user agent and ip during login
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-chaturvedi committed Sep 25, 2023
1 parent 417c116 commit 4521be4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frontend/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export const authOptions: NextAuthOptionsCallback = (_req, res) => {
}

try {
//get client user agent and ip
const userAgent = _req.headers['user-agent']
const ip = _req.headers['x-forwarded-for']

const response = await axios.post<AccessTokenResponse>(
UrlUtils.makeUrl(
process.env.BACKEND_API_BASE!,
Expand All @@ -83,7 +87,13 @@ export const authOptions: NextAuthOptionsCallback = (_req, res) => {
account.provider
),
loginPayload,
{ withCredentials: true }
{
withCredentials: true,
headers: {
'User-agent': userAgent,
'X-forwarded-for': ip,
},
}
)

Object.entries(response.headers).forEach(([k, v]) => {
Expand Down

0 comments on commit 4521be4

Please sign in to comment.