jasonkuhrt / graphql-request

Minimal GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do get the IP address of the client in the request middleware?

KingJammin opened this issue · comments

Perceived Problem

Unable to get the client IP address in the middleware function.

  const paramsLocale = (await getParamsLocaleCookie()) as string
  const userLocale = (await getUserLocaleCookie()) as string

  const language = paramsLocale || userLocale
  console.log('REQUEST MIDDLEWARE', request)

  return {
    ...request,
    headers: {
      ...request.headers,
      'X-Client-Platform': 'web',
      'X-Client-Version': packageJson.version || 'default-version',
      channelID,
      ...(language ? { language } : {})
    }
  }
}

Does anyone know how to get the IP address of the client from within the middleware?