From ea5a78208b418e7bb8646f5c5e46fad497a3100c Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 14 May 2026 14:55:50 +0300 Subject: [PATCH] Return 404 response if tournament id is not matching on match page Just to avoid the page crashing if they somehow ended on URL like this --- .../tournament-match/TournamentMatchRepository.server.ts | 1 + .../tournament-match/loaders/to.$id.matches.$mid.server.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/features/tournament-match/TournamentMatchRepository.server.ts b/app/features/tournament-match/TournamentMatchRepository.server.ts index 757eebb18..8666f518e 100644 --- a/app/features/tournament-match/TournamentMatchRepository.server.ts +++ b/app/features/tournament-match/TournamentMatchRepository.server.ts @@ -39,6 +39,7 @@ export async function findMatchById(id: number) { "Tournament.mapPickingStyle", "TournamentRound.id as roundId", "TournamentRound.maps as roundMaps", + "Tournament.id as tournamentId", jsonArrayFrom( eb .selectFrom("TournamentTeamMember") diff --git a/app/features/tournament-match/loaders/to.$id.matches.$mid.server.ts b/app/features/tournament-match/loaders/to.$id.matches.$mid.server.ts index d568e10bc..8601f1d24 100644 --- a/app/features/tournament-match/loaders/to.$id.matches.$mid.server.ts +++ b/app/features/tournament-match/loaders/to.$id.matches.$mid.server.ts @@ -43,6 +43,10 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { await TournamentMatchRepository.findMatchById(matchId), ); + if (match.tournamentId !== tournamentId) { + throw new Response(null, { status: 404 }); + } + const isBye = !match.opponentOne || !match.opponentTwo; if (isBye) { throw new Response(null, { status: 404 });