Skip to content

Commit

Permalink
Improve the priority of obtaining IP address from header x-real-ip (#…
Browse files Browse the repository at this point in the history
…732)
  • Loading branch information
guandeng authored Nov 5, 2024
1 parent f0e29fd commit 5dae881
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Middleware/TelescopeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function requestHandled($request, $response)
/** @var Dispatched $dispatched */
$dispatched = $psr7Request->getAttribute(Dispatched::class);
$entry = IncomingEntry::make([
'ip_address' => $psr7Request->getServerParams()['remote_addr'],
'ip_address' => $psr7Request->getHeaderLine('x-real-ip') ?: $psr7Request->getServerParams()['remote_addr'] ?? 'unknown',
'uri' => $psr7Request->getRequestTarget(),
'method' => $psr7Request->getMethod(),
'controller_action' => $dispatched->handler ? $dispatched->handler->callback : '',
Expand Down

0 comments on commit 5dae881

Please sign in to comment.