fix(achievements): inject Authorization header in plugin API calls

This commit is contained in:
treydong 2026-05-10 22:43:36 +08:00 committed by Teknium
parent 771b8c4a36
commit da2ed478b5

View file

@ -50,7 +50,9 @@
async function api(path, options) {
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) {
const text = await res.text().catch(function () { return res.statusText; });
throw new Error(res.status + ": " + text);