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

The getTranslations and useTranslations methods will fail when the server component sets dynamic to force-static #1319

Closed
3 tasks done
luokelong opened this issue Sep 3, 2024 · 2 comments
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@luokelong
Copy link

luokelong commented Sep 3, 2024

Description

I used the "export const dynamic = "force-static"; " syntax in the server component to make the cache-control attribute of the header set in the middleware take effect. Unfortunately, at this time, using the "const t = await getTranslations();" or "const t= useTranslations();" methods in page.tsx will fail and the page will return a not found 404 page.

"next": "14.2.1",
"next-intl": "^3.11.1",

App Router with src dir

Verifications

  • I've verified that the problem I'm experiencing isn't covered in the docs.
  • I've searched for similar, existing issues on GitHub and Stack Overflow.
  • I've compared my app to a working example to look for differences.

Mandatory reproduction URL

App Router

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Click on …
  3. See error: …
  4. no more

Expected behaviour

Work well

@luokelong luokelong added bug Something isn't working unconfirmed Needs triage. labels Sep 3, 2024
@amannn
Copy link
Owner

amannn commented Sep 4, 2024

force-static is not intended to be supported, this section should be linked to from an error you're probably seeing in your app. To implement static rendering properly, please follow the static rendering guide (theoretically, after you've set this up, force-static might even work).

to make the cache-control attribute of the header set in the middleware take effect

Is that actually the case? That's quite interesting, I wonder if that behavior is intended.

@amannn amannn closed this as completed Sep 4, 2024
@luokelong
Copy link
Author

force-static is not intended to be supported, this section should be linked to from an error you're probably seeing in your app. To implement static rendering properly, please follow the static rendering guide (theoretically, after you've set this up, force-static might even work).

to make the cache-control attribute of the header set in the middleware take effect

Is that actually the case? That's quite interesting, I wonder if that behavior is intended.

The problem has been solved with your help, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants