add faq for basic auth quirk, fix endless cover loading when backend is down
MREADME.md
@@ -35,7 +35,7 @@ You can configure the backend with the following environment variables:
- `EXCLUDE_EXTENSION`: comma-separated list of of file extensions to ignore completely, e.g. `txt,log,nfo`. If unset, uses a safe set of text files common in downloaded music archives. Useful because some files can get mis-scanned, e.g. some CD-scan .log files get scanned as mp1
## Important Notes
- **No Authentication**: The app has no built-in auth. Run it behind a proxy with basic auth for security.
- **No Authentication**: The app has no built-in auth. Run it behind a proxy with basic auth for security. Simple login form might get added in the future.
## Non-Goals
- **Metadata-Based Views**: No support for filtering by genre, artist, etc. Use other projects for this
@@ -49,6 +49,8 @@ You can configure the backend with the following environment variables:
- I'm getting "Quota exceeded" errors when trying to sync files *or*
- My synced files randomly don't work, are missing
- By default websites aren't granted infinite storage or have persisten data. The frontend requests these permissions by calling `navigator.storage.persist()` on startup, which causes some browsers to show a permissions popup (e.g. firefox), while others just seem to ignore this request and use a heuristic like interaction amount and bookmarking instead. So if you have the error described above you either are running out of actual disk storage, or you need to check what heuristics your browser uses and trigger them.
- My server is online, but I'm getting loading failed errors for everything
- If you have set up basic auth, then the PWA can interact in a weird way with it, where the pwa itself loads fine because it loaded from cache, but any request fails because the basic auth is gone. Usually can be fixed by loading the page, waiting a few seconds and then reloading, which should give you the auth prompt.
## Known issues
- Range requests are not correctly handled in Bun right now, and e.g. doesn't send the total byte length correctly. I worked around this by sending a chunked transfer-encoded response, and setting the range and content-length header manually, which seems to work with the browsers I tested, but still might cause issues in some cases
Mwebclient/src/offline.ts
@@ -289,21 +289,25 @@ export async function listFiles(dir: string, offline: boolean, recursive: boolea
//get cover art for a directory with cache-first strategy
export async function getCover(dir: string, offline: boolean) {
const cached = await db.covers.get(dir);
if (cached !== undefined) {
return cached.data === null ? undefined : URL.createObjectURL(new Blob([cached.data]));
}
try {
const cached = await db.covers.get(dir);
if (cached !== undefined) {
return cached.data === null ? undefined : URL.createObjectURL(new Blob([cached.data]));
}
if (offline) return undefined;
if (offline) return undefined;
const response = await fetch(`/cover/${encodePath(dir)}`, { method: "GET" }).catch(() => {});
if (!response || response.status === 404) {
await db.covers.put({ path: dir, data: null });
const response = await fetch(`/cover/${encodePath(dir)}`, { method: "GET" }).catch(() => {});
if (!response || response.status === 404) {
await db.covers.put({ path: dir, data: null });
return undefined;
}
const blob = await response.blob();
await db.covers.put({ path: dir, data: blob });
return URL.createObjectURL(blob);
} catch {
return undefined;
}
const blob = await response.blob();
await db.covers.put({ path: dir, data: blob });
return URL.createObjectURL(blob);
}
export const clearCoverCache = async (path: string) => {