Skip to content

Commit

Permalink
Merge pull request #412 from MinBZK/fix-publication-pages-not-returni…
Browse files Browse the repository at this point in the history
…ng-404-page

Publication pages not showing 404 page when publication doesn't exist
  • Loading branch information
onursagir authored Dec 4, 2023
2 parents 52c905c + 88814fb commit 7cd90f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-cups-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'web': patch
---

404 page not showing when navigating to a publication that doesn't exist
8 changes: 6 additions & 2 deletions apps/web/src/app/(common-page)/publicaties/[...slug]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fs from 'fs/promises';
import { notFound } from 'next/navigation';

export async function GET(request: Request) {
const enhancedUrl = new URL(request.url);
Expand All @@ -13,7 +12,12 @@ export async function GET(request: Request) {
.then(() => true)
.catch(() => false);

if (!publicationExists) notFound();
if (!publicationExists) {
const url = new URL('/404', request.url);
const response = await fetch(url.toString());

return new Response(response.body);
}

const buffer = await fs.readFile(publicationPath);

Expand Down

0 comments on commit 7cd90f0

Please sign in to comment.