Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile - client component sitemap.ts calling a Server Component #258

Closed
cborgia opened this issue Jul 7, 2023 · 1 comment
Closed

Comments

@cborgia
Copy link

cborgia commented Jul 7, 2023

when building locally, seeing

Failed to compile.

./app/sitemap.ts
ReactServerComponentsError:

You're importing a component that needs next/headers. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.
Learn more: https://nextjs.org/docs/getting-started/react-essentials

   ╭─[/Users/chris/Repos/mine/Techtegrity/ubaldo/app/sitemap.ts:1:1]
 1 │ import prisma from "#/lib/prisma";
 2 │ import { headers } from "next/headers";
   · ───────────────────────────────────────
 3 │ import { getDomain } from "#/lib/utils";
 4 │ import { allChangelogPosts, allLegalPosts } from "contentlayer/generated";
   ╰────

One of these is marked as a client entry with "use client":
  ./app/sitemap.ts
@steven-tey
Copy link
Collaborator

Ah yes, good catch! This is a Next.js bug that is being fixed – for now, downgrading to 13.4.9 should work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants