hermes-agent/apps/desktop/electron/oauth-net-request.ts
2026-07-08 16:24:16 -07:00

18 lines
528 B
TypeScript

/**
* Helpers for Electron net.request calls that ride the OAuth session partition.
*
* Electron's ClientRequest forbids app-set restricted headers such as
* Content-Length. Let Chromium frame the body itself; only set the JSON content
* type here.
*/
function serializeJsonBody(body) {
return body === undefined ? undefined : Buffer.from(JSON.stringify(body))
}
function setJsonRequestHeaders(request) {
request.setHeader('Content-Type', 'application/json')
}
export { serializeJsonBody,
setJsonRequestHeaders }