Skip to content

Commit dc0ea8a

Browse files
committed
Catch fetchDeployMetadata error and redirect to 404 (#5380)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances error handling in the `page.tsx` files for the `publish` and `deploy` routes. It introduces checks to call `notFound()` when metadata cannot be fetched, improving user experience by handling cases where the requested data is unavailable. ### Detailed summary - In `apps/dashboard/src/app/(dashboard)/contracts/publish/[publish_uri]/page.tsx`: - Added a check for `publishMetadataFromUri` and called `notFound()` if it is not present. - In `apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx`: - Added a check for `metadata` and called `notFound()` if it is not present. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent e4b4008 commit dc0ea8a

File tree

2 files changed

+12
-2
lines changed
  • apps/dashboard/src/app/(dashboard)/contracts

2 files changed

+12
-2
lines changed

apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getThirdwebClient } from "@/constants/thirdweb.server";
2+
import { notFound } from "next/navigation";
23
import { fetchDeployMetadata } from "thirdweb/contract";
34
import { DeployContractInfo } from "../../../published-contract/components/contract-info";
45
import { DeployFormForUri } from "../../../published-contract/components/uri-based-deploy";
@@ -16,7 +17,12 @@ export default async function DirectDeployPage(props: DirectDeployPageProps) {
1617
client: getThirdwebClient(),
1718
// force `ipfs://` prefix
1819
uri: parsedUri.startsWith("ipfs://") ? parsedUri : `ipfs://${parsedUri}`,
19-
});
20+
}).catch(() => null);
21+
22+
if (!metadata) {
23+
notFound();
24+
}
25+
2026
return (
2127
<div className="container flex flex-col gap-4 py-8">
2228
<DeployContractInfo

apps/dashboard/src/app/(dashboard)/contracts/publish/[publish_uri]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export default async function PublishContractPage(
2525
const publishMetadataFromUri = await fetchDeployMetadata({
2626
uri: publishUri,
2727
client: getThirdwebClient(),
28-
});
28+
}).catch(() => null);
29+
30+
if (!publishMetadataFromUri) {
31+
notFound();
32+
}
2933

3034
let publishMetadata = publishMetadataFromUri;
3135

0 commit comments

Comments
 (0)