修复博客ip错误

This commit is contained in:
2025-06-20 00:42:03 +08:00
parent 35525f61e6
commit 5bd11d9c07

View File

@@ -63,7 +63,6 @@ export class BlogController {
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string, @Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
@Body() commentData: createBlogCommentDto, @Body() commentData: createBlogCommentDto,
@Req() req, @Req() req,
@Ip() ip,
) { ) {
const { userId } = req.user || {}; const { userId } = req.user || {};
const blog = await this.blogService.findById(id); const blog = await this.blogService.findById(id);
@@ -71,6 +70,7 @@ export class BlogController {
const user = userId ? await this.userService.findById(userId) : null; const user = userId ? await this.userService.findById(userId) : null;
const ip = req.headers['x-forwarded-for'] || req.ip;
// 获取IP归属地 // 获取IP归属地
let address = '未知'; let address = '未知';
if (!['::1'].includes(ip)) { if (!['::1'].includes(ip)) {