fix(tracker-web): do not send Content-Type on bodyless fleet proxy POSTs
Operator actions (ship/requeue/cancel) are bodyless POSTs. The proxy always set Content-Type: application/json, so the backend rejected them with FST_ERR_CTP_EMPTY_JSON_BODY (500). Only declare the JSON content type when a body is actually forwarded. Fixes the fleet dashboard action buttons. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
32e426d423
commit
c1aad8a819
@ -18,7 +18,7 @@ async function proxy(req: NextRequest, { params }: { params: Promise<{ path: str
|
||||
});
|
||||
|
||||
try {
|
||||
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
|
||||
const headers: Record<string, string> = {};
|
||||
const auth = req.headers.get('authorization');
|
||||
if (auth) headers['Authorization'] = auth;
|
||||
|
||||
@ -37,7 +37,13 @@ async function proxy(req: NextRequest, { params }: { params: Promise<{ path: str
|
||||
|
||||
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
||||
const body = await req.text();
|
||||
if (body) fetchOptions.body = body;
|
||||
if (body) {
|
||||
fetchOptions.body = body;
|
||||
// Only declare a JSON body when there actually is one — bodyless POSTs
|
||||
// (operator actions: ship/requeue/cancel) must NOT send Content-Type, or
|
||||
// the backend rejects them with FST_ERR_CTP_EMPTY_JSON_BODY.
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
}
|
||||
|
||||
const res = await fetch(url.toString(), fetchOptions);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user