Skip to content

Commit ecf4a43

Browse files
committed
存在しないページを開いても404にならなかったのを修正
1 parent 8ef4f39 commit ecf4a43

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/[docs_id]/page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ export default async function Page({
2222
);
2323
} else {
2424
const cfAssets = getCloudflareContext().env.ASSETS;
25-
mdContent = await cfAssets!
26-
.fetch(`https://assets.local/docs/${docs_id}.md`)
27-
.then((res) => res.text());
25+
const mdRes = await cfAssets!.fetch(
26+
`https://assets.local/docs/${docs_id}.md`
27+
);
28+
if (mdRes.ok) {
29+
mdContent = await mdRes.text();
30+
} else {
31+
notFound();
32+
}
2833
}
2934
} catch (error) {
3035
console.error(error);

0 commit comments

Comments
 (0)