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

Next.js 15 breaks alternate links #1442

Open
amannn opened this issue Oct 22, 2024 · 4 comments
Open

Next.js 15 breaks alternate links #1442

amannn opened this issue Oct 22, 2024 · 4 comments
Labels
bug Something isn't working upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)

Comments

@amannn
Copy link
Owner

amannn commented Oct 22, 2024

Recent canary versions of Next.js 15 as well as the stable version that was released yesterday break alternate links if you're using next/font or next/image with priority.

This header is important for apps that use i18n routing and the alternateLinks feature (which is turned on by default). Failing to return this header can result in content being marked as duplicate by search engines.

Upstream bug report: vercel/next.js#69000 (comment)

I'm currently waiting for this to be resolved upstream before updating the examples and the bug repro to use Next.js 15.

As a workaround, you can use a sitemap to instruct search engines about multiple variants of your pages.

@Wiibleyde
Copy link

Hello, I think it's a part of the problem enounced here (if it's not i'm sorryyy), I have this error :

Error: Route "/[locale]" used `headers().get('X-NEXT-INTL-LOCALE')`. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at createHeadersAccessError (turbopack://[project]/node_modules/next/src/server/request/headers.ts:487:9)
    at getMessage (turbopack://[project]/node_modules/next/src/server/create-deduped-by-callsite-server-error-logger.ts:46:20)
    at warnForSyncAccess (turbopack://[project]/node_modules/next/src/server/request/headers.ts:473:2)
    at syncIODev (turbopack://[project]/node_modules/next/src/server/request/headers.ts:376:8)
    at <unknown> (turbopack://[project]/node_modules/next-intl/dist/esm/server/react-server/RequestLocaleLegacy.js:1:278)
    at apply (file:///home/wiibleyde/Alternance/lex-port-cartel/node_modules/next/dist/compiled/next-server/dist/compiled/react/cjs/react.react-server.development.js:888:26)
    at s (turbopack://[project]/node_modules/next-intl/dist/esm/server/react-server/RequestLocaleLegacy.js:1:996)
    at get locale [as locale] (turbopack://[project]/node_modules/next-intl/dist/esm/server/react-server/getConfig.js:1:874)
    at <unknown> (turbopack://[project]/src/i18n/request.ts:5:41)
    at <unknown> (turbopack://[project]/node_modules/next-intl/dist/esm/server/react-server/getConfig.js:1:939)
    at apply (file:///home/wiibleyde/Alternance/lex-port-cartel/node_modules/next/dist/compiled/next-server/dist/compiled/react/cjs/react.react-server.development.js:888:26)
    at <unknown> (turbopack://[project]/node_modules/next-intl/dist/esm/server/react-server/getConfig.js:1:1446)
    at apply (file:///home/wiibleyde/Alternance/lex-port-cartel/node_modules/next/dist/compiled/next-server/dist/compiled/react/cjs/react.react-server.development.js:888:26)
    at r (turbopack://[project]/node_modules/next-intl/dist/esm/react-server/useConfig.js:1:436)
    at o (turbopack://[project]/node_modules/next-intl/dist/esm/react-server/useTranslations.js:1:168)
    at Loading (turbopack://[project]/src/app/[locale]/loading.tsx:6:30)
> 1 | import{headers as e}from"next/headers";import{notFound as t}from"next/navigation";import{cache as n}from"react";import{HEADER_LOCALE_NAME as o}from"../../shared/constants.js";import{getCachedRequestLocale as r}from"./RequestLocaleCache.js";const i=n((function(){let n;try{n=e().get(o)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:e}):e}return n||(console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n"),t()),n}));function s(){return r()||i()}export{s as getRequestLocale};

With this packages :
"dependencies": {
"axios": "^1.7.7",
"next": "^15.0.2",
"next-intl": "^3.24.0",
"react": "19.0.0-rc-69d4b800-20241021",
"react-bootstrap-icons": "^1.11.4",
"react-dom": "19.0.0-rc-69d4b800-20241021",
"react-google-recaptcha-v3": "^1.10.1"
},

Any ideas if it's my fault ? (it's possible, I'm a junior developper)

@amannn
Copy link
Owner Author

amannn commented Oct 31, 2024

Hey @Wiibleyde, nope—that's a different story. You're looking for this: await requestLocale.

@Wiibleyde
Copy link

Wiibleyde commented Oct 31, 2024

Oh okay ! Thanks ! and sorry...

@amannn
Copy link
Owner Author

amannn commented Dec 3, 2024

I opened a PR yesterday over at the Next.js repo to address this: vercel/next.js#73431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)
Projects
None yet
Development

No branches or pull requests

2 participants