fix: add x-hermes-session-token header for remote auth
This commit is contained in:
parent
18628e9e36
commit
7435a418c8
|
|
@ -6,9 +6,16 @@
|
||||||
const { useState, useEffect, useCallback } = SDK.hooks;
|
const { useState, useEffect, useCallback } = SDK.hooks;
|
||||||
const { Card, CardHeader, CardTitle, CardContent, Button } = SDK.components;
|
const { Card, CardHeader, CardTitle, CardContent, Button } = SDK.components;
|
||||||
|
|
||||||
// Use native fetch with credentials for remote dashboard
|
// Use native fetch with session token header for remote dashboard
|
||||||
|
function getSessionToken() {
|
||||||
|
return window.__HERMES_SESSION_TOKEN__ || "";
|
||||||
|
}
|
||||||
|
|
||||||
async function apiFetch(path) {
|
async function apiFetch(path) {
|
||||||
const res = await fetch(path, { credentials: "include" });
|
const res = await fetch(path, {
|
||||||
|
credentials: "include",
|
||||||
|
headers: { "x-hermes-session-token": getSessionToken() }
|
||||||
|
});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
throw new Error("API error " + res.status + ": " + text.slice(0, 100));
|
throw new Error("API error " + res.status + ": " + text.slice(0, 100));
|
||||||
|
|
@ -19,7 +26,8 @@
|
||||||
async function apiPost(path) {
|
async function apiPost(path) {
|
||||||
const res = await fetch(path, {
|
const res = await fetch(path, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include"
|
credentials: "include",
|
||||||
|
headers: { "x-hermes-session-token": getSessionToken() }
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue