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

Cloudfront fails to do locale based 404 with Next.js app

Open jamesknightsonos opened this issue 4 years ago • 4 comments

Before opening, please confirm:

App Id

dh2ndod2t9wbt/dev/479

Region

us-east-1

Amplify Console feature

Not applicable

Describe the bug

When deploying to amplify, somehow the translated 404 response from the underlying Next.js server is dropped and replaced with an english version of the 404. We have tested the build locally and am unable to reproduce the behavior.

Example test paths /fr-fr/invalid-page-here-123 => Shows english 404 => BUG /fr-fr/404 => shows French 404 (only exception) => PROPER

I think there is some Cloudfront configuration or something in the amplify stuff that has an internal rewrite for 404s that misses the locale in the path. I noticed there are significantly varying cloudfront request and response headers between these two routes.

Expected behavior

The 404 page should respect the locale in the path variables for next.js 404 page to be correctly translated. /fr-fr/invalid-page-here-123 => Should show French 404 /fr-fr/404 => Should show French 404 (already does and should not change)

Reproduction steps

  1. Go to /fr-fr/invalid-page-here-123
  2. Observe english page

Build Settings

No response

Additional information

No response

jamesknightsonos avatar Oct 14 '21 18:10 jamesknightsonos

Hi :wave:, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

github-actions[bot] avatar Oct 14 '21 18:10 github-actions[bot]

Hi @jamesknightsonos 👋🏽, thanks for raising this! We are investigating this issue and will update once we have more information. Thanks!

ghost avatar Oct 15 '21 16:10 ghost

Hello just wanted to ask if there's any update or any further information required. Could we setup a meeting?

jamesknightsonos avatar Nov 05 '21 19:11 jamesknightsonos

Hello -- Any chance you could see if locale detection is working for your work? We just made improvements to forward the Accept-Language header which should help with this!

https://aws.amazon.com/blogs/mobile/cdn-caching-improvements-for-better-app-performance-with-aws-amplify-hosting/

mauerbac avatar Aug 13 '24 21:08 mauerbac