mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
feat(web): move from react-router to @tanstack/router (#1338)
* fix(auth): invalid cookie handling and wrongful basic auth invalidation * fix(auth): fix test to reflect new HTTP status code * fix(auth/web): do not throw on error * fix(http): replace http codes in middleware to prevent basic auth invalidation fix typo in comment * fix test * fix(web): api client handle 403 * refactor(http): auth_test use testify.assert * refactor(http): set session opts after valid login * refactor(http): send more client headers * fix(http): test * refactor(web): move router to tanstack/router * refactor(web): use route loaders and suspense * refactor(web): useSuspense for settings * refactor(web): invalidate cookie in middleware * fix: loclfile * fix: load filter/id * fix(web): login, onboard, types, imports * fix(web): filter load * fix(web): build errors * fix(web): ts-expect-error * fix(tests): filter_test.go * fix(filters): tests * refactor: remove duplicate spinner components refactor: ReleaseTable.tsx loading animation refactor: remove dedicated `pendingComponent` for `settingsRoute` * fix: refactor missed SectionLoader to RingResizeSpinner * fix: substitute divides with borders to account for unloaded elements * fix(api): action status URL param * revert: action status URL param add comment * fix(routing): notfound handling and split files * fix(filters): notfound get params * fix(queries): colon * fix(queries): comments ts-ignore * fix(queries): extract queryKeys * fix(queries): remove err * fix(routes): move zob schema inline * fix(auth): middleware and redirect to login * fix(auth): failing test * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix(logs): invalidate correct key * fix: JSX element stealing focus from searchbar * reimplement empty release table state text * fix(context): use deep-copy * fix(releases): empty state and filter input warnings * fix(releases): empty states * fix(auth): onboarding * fix(cache): invalidate queries --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
cc9656cd41
commit
1a23b69bcf
64 changed files with 2543 additions and 2091 deletions
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
|
||||
import { baseUrl, sseBaseUrl } from "@utils";
|
||||
import { AuthContext } from "@utils/Context";
|
||||
import { GithubRelease } from "@app/types/Update";
|
||||
|
||||
type RequestBody = BodyInit | object | Record<string, unknown> | null;
|
||||
|
@ -30,7 +29,8 @@ export async function HttpClient<T = unknown>(
|
|||
): Promise<T> {
|
||||
const init: RequestInit = {
|
||||
method: config.method,
|
||||
headers: { "Accept": "*/*" }
|
||||
headers: { "Accept": "*/*", 'x-requested-with': 'XMLHttpRequest' },
|
||||
credentials: "include",
|
||||
};
|
||||
|
||||
if (config.body) {
|
||||
|
@ -87,22 +87,17 @@ export async function HttpClient<T = unknown>(
|
|||
return Promise.resolve<T>({} as T);
|
||||
}
|
||||
case 401: {
|
||||
// Remove auth info from localStorage
|
||||
AuthContext.reset();
|
||||
|
||||
// Show an error toast to notify the user what occurred
|
||||
// return Promise.reject(new Error(`[401] Unauthorized: "${endpoint}"`));
|
||||
return Promise.reject(response);
|
||||
// return Promise.reject(new Error(`[401] Unauthorized: "${endpoint}"`));
|
||||
}
|
||||
case 403: {
|
||||
// Remove auth info from localStorage
|
||||
AuthContext.reset();
|
||||
|
||||
// Show an error toast to notify the user what occurred
|
||||
return Promise.reject(response);
|
||||
}
|
||||
case 404: {
|
||||
return Promise.reject(new Error(`[404] Not found: "${endpoint}"`));
|
||||
const isJson = response.headers.get("Content-Type")?.includes("application/json");
|
||||
const json = isJson ? await response.json() : null;
|
||||
return Promise.reject<T>(json as T);
|
||||
// return Promise.reject(new Error(`[404] Not Found: "${endpoint}"`));
|
||||
}
|
||||
case 500: {
|
||||
const health = await window.fetch(`${baseUrl()}api/healthz/liveness`);
|
||||
|
@ -326,6 +321,8 @@ export const APIClient = {
|
|||
if (filter.id == "indexer") {
|
||||
params["indexer"].push(filter.value);
|
||||
} else if (filter.id === "action_status") {
|
||||
params["push_status"].push(filter.value); // push_status is the correct value here otherwise the releases table won't load when filtered by push status
|
||||
} else if (filter.id === "push_status") {
|
||||
params["push_status"].push(filter.value);
|
||||
} else if (filter.id == "name") {
|
||||
params["q"].push(filter.value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue