Skip to content

Commit

Permalink
feat: add noindex to route
Browse files Browse the repository at this point in the history
  • Loading branch information
mfts committed Oct 6, 2024
1 parent 083d1cb commit 98e6c4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/middleware/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export default async function DomainMiddleware(req: NextRequest) {
// Subdomain available, rewriting
// >>> Rewriting: ${path} to /view/domains/${host}${path}`
url.pathname = `/view/domains/${host}${path}`;
return NextResponse.rewrite(url, PAPERMARK_HEADERS);
const response = NextResponse.rewrite(url, PAPERMARK_HEADERS);

// Add X-Robots-Tag header for custom domain routes
response.headers.set("X-Robots-Tag", "noindex");
return response;
} else {
// redirect plain custom domain to papermark.io, eventually to it's own landing page
return NextResponse.redirect(
Expand Down
9 changes: 9 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const nextConfig = {
},
],
},
{
source: "/view/:path*",
headers: [
{
key: "X-Robots-Tag",
value: "noindex",
},
],
},
];
},
experimental: {
Expand Down

0 comments on commit 98e6c4a

Please sign in to comment.