File size: 532 Bytes
361e46e | 1 2 3 4 5 6 7 8 9 10 11 | // Appends the session token to protected /cache image URLs so the authenticated
// /cache route can verify the viewer owns the project. <img> tags can't send
// Authorization headers, so the token rides as a query param instead.
export function cacheUrl(url) {
if (!url || typeof url !== 'string' || !url.startsWith('/cache/')) return url;
const token = localStorage.getItem('qto_token') || '';
if (!token) return url;
const sep = url.includes('?') ? '&' : '?';
return `${url}${sep}token=${encodeURIComponent(token)}`;
}
|