Skip to content

Commit

Permalink
handle redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Oct 8, 2024
1 parent 4ab4902 commit eaedbd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/explorer/src/app/(explorer)/[chainName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ type Props = {
};

export default async function ChainPage({ params }: Props) {
return redirect(`/${params.chainName}/worlds`);
const { chainName } = params;
const worldAddress = process.env.WORLD_ADDRESS;

if (worldAddress) return redirect(`/${chainName}/worlds/${worldAddress}`);
return redirect(`/${chainName}/worlds`);
}
3 changes: 3 additions & 0 deletions packages/explorer/src/app/(explorer)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default function IndexPage() {
const chainId = Number(process.env.CHAIN_ID);
validateChainId(chainId);

const worldAddress = process.env.WORLD_ADDRESS;
const chainName = chainIdToName[chainId] ?? "anvil";

if (worldAddress) return redirect(`/${chainName}/worlds/${worldAddress}`);
return redirect(`/${chainName}/worlds`);
}

0 comments on commit eaedbd8

Please sign in to comment.