mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-23 05:31:23 +00:00
fix(achievements): inject Authorization header in plugin API calls
This commit is contained in:
parent
771b8c4a36
commit
da2ed478b5
1 changed files with 3 additions and 1 deletions
|
|
@ -50,7 +50,9 @@
|
||||||
|
|
||||||
async function api(path, options) {
|
async function api(path, options) {
|
||||||
const url = "/api/plugins/hermes-achievements" + path;
|
const url = "/api/plugins/hermes-achievements" + path;
|
||||||
const res = await fetch(url, options || {});
|
const token = window.__HERMES_SESSION_TOKEN__ || "";
|
||||||
|
const headers = { ...(options?.headers || {}), Authorization: `Bearer ${token}` };
|
||||||
|
const res = await fetch(url, { ...options, headers });
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const text = await res.text().catch(function () { return res.statusText; });
|
const text = await res.text().catch(function () { return res.statusText; });
|
||||||
throw new Error(res.status + ": " + text);
|
throw new Error(res.status + ": " + text);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue