UNPKG

nuxt-kql

Version:

Kirby's Query Language API for Nuxt

20 lines (19 loc) 547 B
export function getProxyPath(key) { return `/api/__kirby__/${encodeURIComponent(key)}`; } export function headersToObject(headers = {}) { return Object.fromEntries(new Headers(headers)); } export function createAuthHeader({ auth, token, credentials }) { if (auth === "basic" && credentials) { const { username, password } = credentials; const encoded = globalThis.btoa(`${username}:${password}`); return { Authorization: `Basic ${encoded}` }; } if (auth === "bearer") return { Authorization: `Bearer ${token}` }; }