amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Support for Internationalized (i18n) automatic locale detection

Open ArianHamdi opened this issue 1 year ago • 9 comments

Before opening, please confirm:

App Id

d2kp69mengqx1w

AWS Region

us-east-1

Amplify Hosting feature

Deployments, SSR

Question

Our next.js 13 application is being migrated to the new amplify hosting compute platform. We need to configure cloud front for two reasons: 1: to redirect "domain.com/restApi/*" to the API gateway so that they won't be resolved in Amplify Hosting. 2: to get the 'Accept-Language' header in middleware to display the website in the user's preferred language.

We previously added path behavior to cloudfront to point "/restApi/*" to an API gateway and let cloudfront distribution allow "Accept-Language" header.

As of now, amplify has full control over cloudfront and we are unsure how to resolve this issues.

Thanks in advance

ArianHamdi avatar Feb 21 '23 11:02 ArianHamdi

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

github-actions[bot] avatar Feb 23 '23 17:02 github-actions[bot]

Hi @ArianHamdi 👋🏽, thanks for raising this question and explaining your use case for these configurations. We do not support modifications to the CloudFront distribution at this time since it is managed by Amplify with the new compute platform. However, we are tracking this as a feature request.

ghost avatar Feb 23 '23 17:02 ghost

Hi @hloriana. Amplify support for Next.js SSR points to automatic locale detection, but I was not able to implement it.

next.config.js has a localeDetection option that automatically redirects users to their preferred language, but the feature does not work on Amplify.

It seems to rely on Accept-Language header, which seems to be blocked by Amplify (It's unclear to me).

On introduce amplify for next.js, I'm not sure why automatic locale detection is added if this header is blocked.

//next.config.js

i18n: {
    locales: ["en", "sv"],
    defaultLocale: "en",
    localeDetection: true
}

Please let me know if this comment needs a new issue.

ArianHamdi avatar Feb 28 '23 13:02 ArianHamdi

@hloriana Do you have any updates about the headers? Http request headers like "Accept-Language" or "Referer" seems not to be passed through Amplify Host. We are stuck in development after migrating our front end to Amplify.

vafPER avatar Mar 02 '23 20:03 vafPER

@hloriana It's hilarious and at the same time sad that we got to know today that what was written in AWS Amplify doc was wrong and Automatic locale detection for Next Js is not supported yet. At least we managed to make them correct their official page :

https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html

so no other team falls into the trap of spending days on finding the cause of an error which is written wrongly as a supported feature.

vafPER avatar Mar 08 '23 22:03 vafPER

Are there any updates on this?

Everything was seamless for hosting Next.js app with Amplify until we have learned the accept-language headers were stripped off from requests by CloudFront and there is no way to configure this behavior. We will stick with Vercel until this one is fixed. Hope this issue is resolved in a timely manner.

burkayanduv avatar Jul 16 '23 20:07 burkayanduv

Any updates for this feature?

gstrobl avatar Nov 14 '23 09:11 gstrobl

+1 This feature request is very important and the lack of language detection (in my case handled by middleware inside of Next.js 14) is what is currently holding me back from hosting on amplify.

mdillgen avatar Feb 07 '24 14:02 mdillgen

try 'cloudfront-viewer-country' field but it is not perfect.

snaps-jacob avatar Feb 19 '24 07:02 snaps-jacob