[Update] Replace redirect with notFound for 404 handling (#4596)

This commit is contained in:
Jonas Daniels
2024-09-14 17:10:18 -07:00
committed by GitHub
parent 1a56ed6214
commit 11437524e4
8 changed files with 13 additions and 14 deletions
@@ -1,6 +1,6 @@
import "server-only"; import "server-only";
import { redirect } from "next/navigation"; import { notFound } from "next/navigation";
import type { ChainCTAProps } from "./[chain_id]/(chainPage)/components/server/cta-card"; import type { ChainCTAProps } from "./[chain_id]/(chainPage)/components/server/cta-card";
import zeroGCTA from "./temp-assets/0gCTA.png"; import zeroGCTA from "./temp-assets/0gCTA.png";
import zeroGBanner from "./temp-assets/0gLabsBanner.png"; import zeroGBanner from "./temp-assets/0gLabsBanner.png";
@@ -89,7 +89,7 @@ export async function getChain(
]); ]);
if (!chain.data) { if (!chain.data) {
redirect("/404"); notFound();
} }
return { return {
...chain.data, ...chain.data,
@@ -1,7 +1,7 @@
import { getProjects } from "@/api/projects"; import { getProjects } from "@/api/projects";
import { getTeams } from "@/api/team"; import { getTeams } from "@/api/team";
import { TabPathLinks } from "@/components/ui/tabs"; import { TabPathLinks } from "@/components/ui/tabs";
import { redirect } from "next/navigation"; import { notFound } from "next/navigation";
import { TeamHeader } from "../../components/TeamHeader/TeamHeader"; import { TeamHeader } from "../../components/TeamHeader/TeamHeader";
export default async function TeamLayout(props: { export default async function TeamLayout(props: {
@@ -18,8 +18,7 @@ export default async function TeamLayout(props: {
); );
if (!team) { if (!team) {
// not a valid team, redirect back to 404 notFound();
redirect("/404");
} }
return ( return (
@@ -11,14 +11,14 @@ export default async function Page(props: {
const project = await getProject(team_slug, project_slug); const project = await getProject(team_slug, project_slug);
if (!project) { if (!project) {
return notFound(); notFound();
} }
// THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object. // THIS IS A WORKAROUND - project does not have `services` info - so we fetch APIKey object.
const apiKey = await getAPIKey(project.id); const apiKey = await getAPIKey(project.id);
if (!apiKey) { if (!apiKey) {
return notFound(); notFound();
} }
return ( return (
@@ -15,7 +15,7 @@ export default async function Page(props: {
); );
if (!project) { if (!project) {
return notFound(); notFound();
} }
return ( return (
@@ -17,7 +17,7 @@ export default async function Page(props: {
); );
if (!project) { if (!project) {
return notFound(); notFound();
} }
const TRACKING_CATEGORY = "team/in-app-wallets"; const TRACKING_CATEGORY = "team/in-app-wallets";
@@ -15,7 +15,7 @@ export default async function Page(props: {
); );
if (!project) { if (!project) {
return notFound(); notFound();
} }
return ( return (
@@ -1,7 +1,7 @@
import { getProjects } from "@/api/projects"; import { getProjects } from "@/api/projects";
import { getTeams } from "@/api/team"; import { getTeams } from "@/api/team";
import { TabPathLinks } from "@/components/ui/tabs"; import { TabPathLinks } from "@/components/ui/tabs";
import { redirect } from "next/navigation"; import { notFound, redirect } from "next/navigation";
import { TeamHeader } from "../../components/TeamHeader/TeamHeader"; import { TeamHeader } from "../../components/TeamHeader/TeamHeader";
export default async function TeamLayout(props: { export default async function TeamLayout(props: {
@@ -14,7 +14,7 @@ export default async function TeamLayout(props: {
if (!team) { if (!team) {
// not a valid team, redirect back to 404 // not a valid team, redirect back to 404
redirect("/404"); notFound();
} }
const teamsAndProjects = await Promise.all( const teamsAndProjects = await Promise.all(
+2 -2
View File
@@ -1,5 +1,5 @@
import { getTeams } from "@/api/team"; import { getTeams } from "@/api/team";
import { redirect } from "next/navigation"; import { notFound, redirect } from "next/navigation";
export default async function TeamRootPage() { export default async function TeamRootPage() {
// get all teams, then go to the first team // get all teams, then go to the first team
@@ -7,7 +7,7 @@ export default async function TeamRootPage() {
const firstTeam = teams[0]; const firstTeam = teams[0];
if (!firstTeam) { if (!firstTeam) {
return redirect("/404"); notFound();
} }
redirect(`/team/${firstTeam.slug}`); redirect(`/team/${firstTeam.slug}`);
} }