feat: track upstream request ID and prevent response header override
When proxying through another new-api instance, the upstream X-Oneapi-Request-Id was overwriting the local one in client responses. This adds a new `upstream_request_id` field to the logs table, captures the upstream ID during relay, and filters it from being copied back to the client. Frontend gains search/filter and detail display support.
This commit is contained in:
@@ -88,6 +88,8 @@ export function CommonLogsFilterBar<TData>(
|
||||
if (searchParams.group) next.group = searchParams.group
|
||||
if (searchParams.username) next.username = searchParams.username
|
||||
if (searchParams.requestId) next.requestId = searchParams.requestId
|
||||
if (searchParams.upstreamRequestId)
|
||||
next.upstreamRequestId = searchParams.upstreamRequestId
|
||||
|
||||
if (Object.keys(next).length > 0) {
|
||||
setFilters((prev) => ({ ...prev, ...next }))
|
||||
@@ -106,6 +108,7 @@ export function CommonLogsFilterBar<TData>(
|
||||
searchParams.group,
|
||||
searchParams.username,
|
||||
searchParams.requestId,
|
||||
searchParams.upstreamRequestId,
|
||||
searchParams.type,
|
||||
])
|
||||
|
||||
@@ -161,7 +164,8 @@ export function CommonLogsFilterBar<TData>(
|
||||
!!filters.token ||
|
||||
!!filters.username ||
|
||||
!!filters.channel ||
|
||||
!!filters.requestId
|
||||
!!filters.requestId ||
|
||||
!!filters.upstreamRequestId
|
||||
|
||||
const hasAdditionalFilters =
|
||||
!!filters.model || !!filters.group || !!logType || hasExpandedFilters
|
||||
@@ -290,6 +294,15 @@ export function CommonLogsFilterBar<TData>(
|
||||
onKeyDown={handleKeyDown}
|
||||
className={inputClass}
|
||||
/>
|
||||
<Input
|
||||
placeholder={t('Upstream Request ID')}
|
||||
value={filters.upstreamRequestId || ''}
|
||||
onChange={(e) =>
|
||||
handleChange('upstreamRequestId', e.target.value)
|
||||
}
|
||||
onKeyDown={handleKeyDown}
|
||||
className={inputClass}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
hasExpandedActiveFilters={hasExpandedFilters}
|
||||
|
||||
@@ -519,6 +519,13 @@ export function DetailsDialog(props: DetailsDialogProps) {
|
||||
mono
|
||||
/>
|
||||
)}
|
||||
{props.log.upstream_request_id && (
|
||||
<DetailRow
|
||||
label={t('Upstream Request ID')}
|
||||
value={props.log.upstream_request_id}
|
||||
mono
|
||||
/>
|
||||
)}
|
||||
|
||||
{props.isAdmin && props.log.channel > 0 && (
|
||||
<DetailRow
|
||||
|
||||
Reference in New Issue
Block a user