Repository: IgnisDa/ryot (language: rust)

Issue:
OIDC broken after upgrading 6.0.1 to 6.3.2
I'm currently running Authentik (2024.6.0) and recently upgraded from ryot 6.0.1 to 6.3.2 and this broke SSO. The following error is all I see in the logs when trying to log in. When I get redirected back to `<FRONTEND_URL>/api/auth` I just get a "you must be logged in" notice in the UI.

```
[frontend] Error: No route matches URL "/favicon.ico"
[frontend]     at getInternalRouterError (/home/ryot/node_modules/@remix-run/router/router.ts:5353:5)
[frontend]     at Object.query (/home/ryot/node_modules/@remix-run/router/router.ts:3462:19)
[frontend]     at handleDocumentRequest (/home/ryot/node_modules/@remix-run/server-runtime/dist/server.js:268:35)
[frontend]     at requestHandler (/home/ryot/node_modules/@remix-run/server-runtime/dist/server.js:160:24)
[frontend]     at /home/ryot/node_modules/@remix-run/express/dist/server.js:41:28
```

The URL it's failing to match has changed once. The first time this happened it was a `.js` file but I don't recall the name and I can't get it to show up again. 

I have ryot deployed with podman quadlets using these unit and .env files:

```
# ryot.container
[Unit]
Requires=ryot-db.service

[Container]
ContainerName=ryot
EnvironmentFile=/opt/podman/ryot/.env
HostName=ryot
Image=ghcr.io/ignisda/ryot:v6.3.2
Label=backup.enable=true service.name=ryot compose.path=/opt/podman/ryot
Network=backend
Network=frontend
NoNewPrivileges=true
PublishPort=25352:8000

[Service]
Restart=on-abnormal

[Install]
WantedBy=default.target
```

```
# ryot-db.container
[Container]
ContainerName=ryot-db
EnvironmentFile=/opt/podman/ryot/.env
HostName=ryot-db
Image=docker.io/postgres:16.3-alpine
Label=backup.enable=true database.type=postgres service.name=ryot-db compose.path=/opt/podman/ryot
Network=backend
NoNewPrivileges=true
Volume=/opt/podman/ryot/data/db_data:/var/lib/postgresql/data:Z
Volume=/opt/podman/ryot/data/backups:/backups:Z

[Service]
Restart=on-abnormal

[Install]
WantedBy=default.target
```

```
# .env
PGID=1000
PUID=1000
TZ=America/Phoenix

POSTGRES_DB=ryot
POSTGRES_HOST=ryot-db
POSTGRES_PASSWORD=REDACTED
POSTGRES_USER=ryot

VIDEO_GAMES_TWITCH_CLIENT_ID=REDACTED
VIDEO_GAMES_TWITCH_CLIENT_SECRET=REDACTED

DATABASE_URL=postgres://ryot:REDACTED@ryot-db:5432/postgres


FRONTEND_URL=https://ryot.int.REDACTED.com
SERVER_OIDC_CLIENT_ID=REDACTED
SERVER_OIDC_CLIENT_SECRET=REDACTED
SERVER_OIDC_ISSUER_URL=https://id.REDACTED.com/application/o/ryot/
```

Authentik is also running in a quadlet and is functioning fine. The only other app I have hooked up to it is Immich which is not having any issues.


Discussion / hints:
Same error here, was running without issues until the update, also using Authentik
Ok, workaround for now (at least to my problem) was to downgrade to v6.3.1
> Ok, workaround for now (at least to my problem) was to downgrade to v6.3.1

This worked for me as well. 

Fix patch:
diff --git a/apps/backend/src/miscellaneous/resolver.rs b/apps/backend/src/miscellaneous/resolver.rs
index a2a00fb65d..e90ff3fbe2 100644
--- a/apps/backend/src/miscellaneous/resolver.rs
+++ b/apps/backend/src/miscellaneous/resolver.rs
@@ -1858,7 +1858,11 @@ impl MiscellaneousService {
                         times_seen: seen.len(),
                     })
                 }
-                let times_season_seen = episodes.iter().map(|e| e.times_seen).min().unwrap();
+                let times_season_seen = episodes
+                    .iter()
+                    .map(|e| e.times_seen)
+                    .min()
+                    .unwrap_or_default();
                 seasons.push(UserMetadataDetailsShowSeasonProgress {
                     episodes,
                     times_seen: times_season_seen,
diff --git a/apps/frontend/app/routes/api.auth.tsx b/apps/frontend/app/routes/api.auth.tsx
index 4178ea3260..076de92974 100644
--- a/apps/frontend/app/routes/api.auth.tsx
+++ b/apps/frontend/app/routes/api.auth.tsx
@@ -6,7 +6,7 @@ import {
 	LoginUserDocument,
 	RegisterUserDocument,
 } from "@ryot/generated/graphql/backend/graphql";
-import { serialize } from "cookie";
+import { type CookieSerializeOptions, serialize } from "cookie";
 import { z } from "zod";
 import { zx } from "zodix";
 import { AUTH_COOKIE_NAME } from "~/lib/generals";
@@ -41,7 +41,10 @@ export const loader = unstable_defineLoader(async ({ request }) => {
 	});
 	if (loginUser.__typename === "LoginResponse") {
 		const cookies = await getCookiesForApplication(loginUser.apiKey);
-		const options = { maxAge: coreDetails.tokenValidForDays * 24 * 60 * 60 };
+		const options = {
+			maxAge: coreDetails.tokenValidForDays * 24 * 60 * 60,
+			path: "/",
+		} satisfies CookieSerializeOptions;
 		return redirect($path("/"), {
 			headers: combineHeaders(
 				{


Test patch: