withHeaders([ 'User-Agent' => (string) $request->userAgent(), 'X-Forwarded-For' => (string) $request->ip(), ]) ->post($url, $request->all()); } catch (ConnectionException $e) { Log::error('Failed to forward Plausible event: '.$e->getMessage()); return response('Bad Gateway', 502); } return response($upstream->body(), $upstream->status()) ->header('Content-Type', $upstream->header('Content-Type') ?: 'text/plain'); } }