'Cloudfront and multiple Country code top-level domains
I did deploy a Next.js application on aws-amplify and everything works fine. Additionally I started to add six custom domains to my application on amplify (mysite.at, mysite.de, mysite.com, mysite.uk, mysite.it and mysite.ch). This works well too.
Now I wanted to use the i18n feature, which nextjs provides.
module.exports = {
generateEtags: false,
i18n: {
locales: ['en-US', 'it-IT', 'de-AT', 'de-DE', 'de-CH', 'en-UK'],
defaultLocale: 'en-US',
localeDetection: false,
domains: [
{
domain: 'www.mysite.com',
defaultLocale: 'en-US',
},
{
domain: 'www.mysite.it',
defaultLocale: 'it-IT',
},
{
domain: 'www.mysite.ch',
defaultLocale: 'de-CH',
},
{
domain: 'www.mysite.at',
defaultLocale: 'de-AT',
},
{
domain: 'www.mysite.de',
defaultLocale: 'de-DE',
},
{
domain: 'www.mysite.uk',
defaultLocale: 'en-UK',
},
],
},
}
It's possible to call www.mysite.com/de-DE and it shows me the page for Germany, ww.mysite.com/it-IT for the italian content and so on.
But when I call www.mysite.at (which should render the content for Austria de-AT) I always get the content from the first call which was made after deployment. In this case I always get the content for Germany.(on every machine I try)
When I empty the cloudfront cache, and call www.mysite.uk I get the content for uk, but when I call www.mysite.de afterwards, I get the uk content again.
When I request with a parameter eg. www.mysite.de/?dsjskdjsaj it does work.
So I think the cloudfront CDN (Lambda@Edge) is the problem in this case. Is it possible to cache the content for each domain? I know there is only one cloudfront distribution for my project, but maybe there is a solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
