Fix flights-map date format and dev proxy empty-body status parsing
Upstream /destinations and /days endpoints expect yyyy-MM-DD (dashed),
matching Angular's ApiFormatterService.formatDateOnly output. React was
sending the internal compact yyyyMMdd, triggering silent 400s.
Also fix dev-server.mjs status-code parsing: empty-body curl responses
start with the appended "\n%{http_code}" separator at index 0, so
`lastNewline > 0` mis-treated the status as body and defaulted to 200,
hiding real upstream 4xx/5xx responses. Changed to `>= 0`.
This commit is contained in:
@@ -133,10 +133,14 @@ function execCurl(args, res) {
|
||||
return;
|
||||
}
|
||||
|
||||
// stdout = body + "\n" + statusCode (from -w "\n%{http_code}")
|
||||
// stdout = body + "\n" + statusCode (from -w "\n%{http_code}"). When
|
||||
// upstream returns an empty body the stdout starts with "\n", so a
|
||||
// `> 0` check mis-treats the status as body and falls back to 200 —
|
||||
// silently hiding real 4xx/5xx responses. Use `>= 0` and split
|
||||
// unconditionally when the newline is present.
|
||||
const lastNewline = stdout.lastIndexOf("\n");
|
||||
const body = lastNewline > 0 ? stdout.substring(0, lastNewline) : stdout;
|
||||
const statusStr = lastNewline > 0 ? stdout.substring(lastNewline + 1).trim() : "200";
|
||||
const body = lastNewline >= 0 ? stdout.substring(0, lastNewline) : stdout;
|
||||
const statusStr = lastNewline >= 0 ? stdout.substring(lastNewline + 1).trim() : "200";
|
||||
const status = parseInt(statusStr) || 200;
|
||||
|
||||
const isJson = body.trimStart().startsWith("{") || body.trimStart().startsWith("[");
|
||||
|
||||
Reference in New Issue
Block a user