Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Language detection in the path and query string works incorrectly on AWS s3 bucket

I am working on React web app and I use i18n and i18next-browser-languagedetector for translation the app. On my local all works fine, even on server all is works in the same way. But I have a problem on aws s3 bucket. After I build my react project and upload it to s3 bucket i18n stop working correctly.

I am new user on aws, so maybe I am doing something wrong, sorry about that.

My s3 bucket configuration:

Static website hosting with following redirection rules

[
    {
        "Condition": {
            "HttpErrorCodeReturnedEquals": "404"
        },
        "Redirect": {
            "HostName": "my-bucket-name.s3-website-sa-east-1.amazonaws.com",
            "ReplaceKeyPrefixWith": "#!/"
        }
    },
    {
        "Condition": {
            "HttpErrorCodeReturnedEquals": "403"
        },
        "Redirect": {
            "HostName": "my-bucket-name.s3-website-sa-east-1.amazonaws.com",
            "ReplaceKeyPrefixWith": "#!/"
        }
    }
]

First I pass current language in the path as my-bucket-name.s3-website-sa-east-1.amazonaws.com/en/ but when I load web app I always see detected language en even if I set another language in the path. Then I tried to put language in query string as my-bucket-name.s3-website-sa-east-1.amazonaws.com/?lang=en and I faced with the same wrong behaviour. screenshot from console My i18n file.

import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
const options = {
    order: ['querystring'],
    lookupQuerystring: 'lng',
};
const languages = ["en", "pt"]

i18n.use(LanguageDetector).init({
    detection: options,
    resources: {...},
    fallbackLng: "en",
    debug: true,
    whitelist: languages,
    checkWhitelist: true ,
    ns: ["translations"],
    defaultNS: "translations",
    keySeparator: false, 
    interpolation: {
        escapeValue: false, 
        formatSeparator: ","
    },
    react: {
        wait: true
    }
});

export default i18n;

I also tried to set fallback language to pt and in this case on aws s3 bucket it always detected as pt even if in path or query string I set en.

So it is always using fallback language for some reason.

Why language detection may not work on aws s3 bucket? Maybe someone faced with similar problem?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I had the same problem, I accidentally found a solution. Check that in the Error document field you have written index.html in the same way as in Index document field. If there is a slash, remove it. The right way to do that Also, make Redirection rules field empty.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda