From 5aa4fee87cdb1f8223e59c058aad8a8c892ae7cf Mon Sep 17 00:00:00 2001 From: Yusuke Tanaka Date: Fri, 17 Nov 2023 16:58:49 +0900 Subject: [PATCH] fix: set `accept: application/x-ndjson` in fetching live logs (#194) This commit sets `accept: application/x-ndjson` header when fetching live logs. Fixes #188 --- src/utils/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/api.ts b/src/utils/api.ts index 9709a83d..8df86db8 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -17,6 +17,7 @@ import { export interface RequestOptions { method?: string; body?: unknown; + accept?: string; } export class APIError extends Error { @@ -94,7 +95,7 @@ export class API { await this.#authorization.get() ?? await this.#authorization.provision() }`; const headers = { - "Accept": "application/json", + "Accept": opts.accept ?? "application/json", "Authorization": authorization, ...(opts.body !== undefined ? opts.body instanceof FormData @@ -187,6 +188,9 @@ export class API { ): AsyncIterable { return this.#requestStream( `/projects/${projectId}/deployments/${deploymentId}/logs/`, + { + accept: "application/x-ndjson", + }, ); }