Download frontend/src/cacheUrl.js from Basel0/qshub: direct link, hf CLI and curl.
- Browser
- Download file 532 Bytes
-
https://huggingface.co/spaces/Basel0/qshub/resolve/main/frontend/src/cacheUrl.js
- Command line
-
hf download hf://spaces/Basel0/qshub/frontend/src/cacheUrl.js
-
curl -L -o cacheUrl.js https://huggingface.co/spaces/Basel0/qshub/resolve/main/frontend/src/cacheUrl.js
532 Bytes
| // 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)}`; | |
| } | |