feat: integrate getClientIPAddress utility for improved IP address retrieval
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { isRouteErrorResponse } from 'react-router'
|
||||
import { getClientIPAddress } from 'remix-utils/get-client-ip-address'
|
||||
import { stripHtml } from 'string-strip-html'
|
||||
|
||||
import { getCategories } from '~/apis/common/get-categories'
|
||||
@@ -13,10 +14,7 @@ import type { Route } from './+types/_news.detail.$slug'
|
||||
|
||||
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
||||
const userAgent = request.headers.get('user-agent')
|
||||
const ipAddress =
|
||||
request.headers.get('cf-connecting-ip') ||
|
||||
request.headers.get('x-forwarded-for') ||
|
||||
'localhost'
|
||||
const ipAddress = getClientIPAddress(request) || 'localhost'
|
||||
const { userToken: accessToken } = await handleCookie(request)
|
||||
let userData
|
||||
if (accessToken) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { data } from 'react-router'
|
||||
import { getClientIPAddress } from 'remix-utils/get-client-ip-address'
|
||||
import { XiorError } from 'xior'
|
||||
|
||||
import { createLogAdsRequest } from '~/apis/news/create-log-ads'
|
||||
@@ -8,10 +9,7 @@ import type { Route } from './+types/actions.log.ads.$id'
|
||||
|
||||
export const action = async ({ request, params }: Route.ActionArgs) => {
|
||||
const userAgent = request.headers.get('user-agent')
|
||||
const ipAddress =
|
||||
request.headers.get('cf-connecting-ip') ||
|
||||
request.headers.get('x-forwarded-for') ||
|
||||
'localhost'
|
||||
const ipAddress = getClientIPAddress(request) || 'localhost'
|
||||
const { userToken: accessToken } = await handleCookie(request)
|
||||
const { id } = params
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user