fix(api): дублировать маршруты под /api и убрать Content-Type у GET
Some checks failed
CI / build-and-test (pull_request) Has been cancelled

This commit is contained in:
Anton
2026-04-08 10:20:17 +03:00
parent 7e9c20d4bf
commit 53b9561a54
5 changed files with 21 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "calendar-run-frontend",
"private": true,
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -35,10 +35,15 @@ export async function requestJson<T>(path: string, init?: RequestInit): Promise<
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
try {
const defaultHeaders: Record<string, string> = {};
if (method !== "GET" && method !== "HEAD") {
defaultHeaders["Content-Type"] = "application/json";
}
const response = await fetch(buildUrl(path), {
...init,
headers: {
"Content-Type": "application/json",
...defaultHeaders,
...(init?.headers ?? {}),
},
});
@@ -55,25 +60,6 @@ export async function requestJson<T>(path: string, init?: RequestInit): Promise<
await delay(80 * attempt);
continue;
}
// #region agent log
fetch("http://127.0.0.1:7488/ingest/a18f912f-72c6-4a58-866b-17810a6b89d2", {
method: "POST",
headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "587ee5" },
body: JSON.stringify({
sessionId: "587ee5",
hypothesisId: "H-http-not-ok",
location: "http.ts:requestJson",
message: "HTTP error response",
data: {
path,
status: response.status,
contentType: response.headers.get("content-type"),
payloadIsObject: payload !== null && typeof payload === "object",
},
timestamp: Date.now(),
}),
}).catch(() => {});
// #endregion
throw toApiError(response.status, payload);
}