aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
457 stars 115 forks source link

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

Open jamesknightsonos opened 3 years ago

jamesknightsonos commented 3 years ago

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

github-actions[bot] commented 3 years ago

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!

ghost commented 3 years ago

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

jamesknightsonos commented 2 years ago

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

mauerbac commented 2 months ago

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/