-
Notifications
You must be signed in to change notification settings - Fork 27k
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
next/font
interferes with header links from middleware.
#69000
Comments
@zenzen-sol This is likely because the headers size was limited, so We expanded these headers →
I am taking a look to confirm! |
Despite the headers size increase, I only see the |
@samcx I can confirm that I'm seeing the same when deploying to Vercel. At this point, I'll assume that the correct header will be set, although I haven't found any way to confirm it locally. (Still seeing only the font optimization headers when running in dev.) Thanks for looking into this! |
@zenzen-sol I am also seeing that on I think what is probably happening is these It's tough to say why it gets flipped and explain why In the meantime, I will be closing this issue! |
Hey @samcx, I hope it's ok for me to chime in. I've tested with the latest canary and am observing the same behavior as you do: In development, only the React optimization header value for There are two aspects here that worry me a bit:
Any chance we could get to the bottom of this and see if there's something to be adjusted in Next.js to work correctly? |
@amannn Thank you for the clarification! I should have also checked Not sure if it's getting "replaced," but I have shared this with our team! |
Awesome, thanks a lot @samcx! |
@samcx I've just tried out Next.js 15 RC 2 and this issue is still present. Are you working on a fix? I also noticed this affects I've simplified the reproduction further:
The expected behavior would be that the Note that the In Next.js 14 this works fine, please ensure a smooth upgrade path for users who rely on this mechanism 🙏 (i.e. most of the people using |
@samcx Unfortunately, this is still the case in the stable release of Next.js 15. Are there plans to fix this? As mentioned in my previous comment, this header is critical for search engines to link content correctly, avoiding marking content as duplicate. |
@amannn There are still plans to fix this, we just did not get to this issue yet! We will get back to you when we have an update on this. |
Got it, thanks! |
Mmmm really this issue is critical, I am being forced to avoid Next/Font until this issue is resolved, could be useful to check this action https://github.com/vercel/next.js/actions/runs/11649654749/job/32437409528?pr=71925 to see if the PR works, the PR seems right |
There is no way to avoid this issue loading all by myself |
Hey I have been looking for a solution for it, this component can be loaded in the Layout and made the same function as the Link Header Layout.tsx const headersStore = await headers();
const host = headersStore.get("host") as string;
const params = await props.params;
const { locale } = params;
// ...
return (
...
<Alternates host={host} locale={locale} />
...
) alternates.tsx"use client";
import { routing, usePathname } from "@/i18n/routing";
import { notFound } from "next/navigation";
type Locale = (typeof routing)["locales"][number];
type Props = {
host: string;
locale: Locale;
};
export default function Alternates({ host, locale }: Props) {
const pathname = usePathname();
if (!routing.locales.includes(locale as Locale)) {
notFound();
}
const path = pathname === "/" ? "" : pathname;
return (
<>
{routing.locales.map((l) => {
return (
<link
key={l}
rel="alternate"
hrefLang={l}
href={`https://${host}/${l}${path}`}
/>
);
})}
<link
rel="alternate"
hrefLang="x-default"
href={`https://${host}${path}`}
/>
</>
);
} |
Link to the code that reproduces this issue
https://github.com/zenzen-sol/next-reproduction-template/tree/sol/repro-001-next-15-broken
To Reproduce
pnpm i && pnpm run dev
http://localhost:3000
in a browser.Examples:
next/font
(NextJS 15.0.0-rc.0): https://github.com/zenzen-sol/next-reproduction-template/tree/sol/repro-001-next-15-workingCurrent vs. Expected behavior
The
next-intl
library's middleware injects "alternate" links into the response header for SEO purposes. At the same time,next/font
injects "preload" header links into the response header. Both sets of links should appear in the response header. This was working correctly in Next 14.Since NextJS 14.3.0-canary.43 and 15.0.0-canary.0, the "alternate" links from
next-intl
are no longer present whennext/font
is used.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Fri Jul 5 17:53:24 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T6020 Available memory (MB): 32768 Available CPU cores: 12 Binaries: Node: 20.11.1 npm: 10.2.4 Yarn: 3.6.1 pnpm: 9.7.1 Relevant Packages: next: 15.0.0-rc.0 // Latest available version is detected (15.0.0-rc.0). eslint-config-next: N/A react: 19.0.0-rc-19bd26be-20240815 react-dom: 19.0.0-rc-19bd26be-20240815 typescript: 5.5.4 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Font (next/font), Internationalization (i18n), Metadata, Middleware
Which stage(s) are affected? (Select all that apply)
next dev (local), Vercel (Deployed)
Additional context
I tested my reproduction against canary releases back to
14.3.0-canary.0
. This issue first appears in v14.3.0-canary.43, and is not present in14.3.0-canary.42
.If I had to guess, the issue is related to the changes made to
packages/next/src/server/app-render/app-render.tsx
in that prerelease.The text was updated successfully, but these errors were encountered: