chore: commit oxfmt formatting changes and verify artifacts
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
* 从请求对象中提取客户端 IP 和 UserAgent
|
||||
*/
|
||||
export function extractRequestInfo(req: any): { ipAddress: string; userAgent: string } {
|
||||
const forwarded = req.headers?.['x-forwarded-for'] || req.headers?.['x-real-ip'] || req.connection?.remoteAddress || '';
|
||||
const forwarded =
|
||||
req.headers?.['x-forwarded-for'] ||
|
||||
req.headers?.['x-real-ip'] ||
|
||||
req.connection?.remoteAddress ||
|
||||
'';
|
||||
const ipAddress = String(forwarded).split(',')[0].trim() || 'unknown';
|
||||
const userAgent = (req.headers?.['user-agent'] || '').substring(0, 500);
|
||||
return { ipAddress, userAgent };
|
||||
|
||||
Reference in New Issue
Block a user