next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: Inconsistent language redirection behavior in Asana Next.js app - Deploy Preview

Open bhavana-netlify opened this issue 2 years ago • 2 comments

Summary

Goal:

  1. Asana want to enable site-wide locale redirections based on a user's accept-language header value and their personal preference (ie. a cookie value such as nf_language).
  2. Asana wants to support 13 languages and as an example, a user who has an accept-language of 'fr' to be redirected from /:path to /fr/:path.

What they have tried so far:

Setting the rules in the _redirects file

  1. implement the rules in their _redirect file like so: /* /fr/* 301! Language=fr 

These are the rules in the _redirect files /%20 / 301 /%E2%80%8E / 301 /guide/* /fr/guide/:splat 301! Language=fr /guide/* /zh-tw/guide/:splat 301! Language=zh-tw /:path /de/:path 301! Language=de /:path /es/:path 301! Language=es /:path /fr/:path 301! Language=fr /:path /id/:path 301! Language=id /:path /it/:path 301! Language=it /:path /ja/:path 301! Language=ja /:path /ko/:path 301! Language=ko /:path /nl/:path 301! Language=nl /:path /pl/:path 301! Language=pl /:path /pt/:path 301! Language=pt /:path /ru/:path 301! Language=ru /:path /sv/:path 301! Language=sv /:path /zh-tw/:path 301! Language=zh-tw / /de 301! Language=de / /es 301! Language=es / /fr 301! Language=fr / /id 301! Language=id / /it 301! Language=it / /ja 301! Language=ja / /ko 301! Language=ko / /nl 301! Language=nl / /pl 301! Language=pl / /pt 301! Language=pt / /ru 301! Language=ru / /sv 301! Language=sv / /zh-tw 301! Language=zh-tw

What they are seeing: inconsistencies in the response from Netlify when a user hits a URL that matches one of the rules.

Implementation Detail:

  1. Asana is building the app using Next.js. Netlify bundles the redirects and adds them to a unified netlify.toml file along with other rules that are part of the Next.js plugin.
  2. These specific routes that match the rule are generated by an ODB

Question I have: AFAIK, we process redirect rules first before we decide how to serve that request (either from cache, function or origin). If this is correct, then their use case should be pretty straightforwardly handled:

If a user were to request /pricing with accept-language 'fr', the redirection rule should match, return a redirect to /fr/pricing, and then either the appropriate cache or ODB result for /fr/pricing should be in the final response.

Is this not the case?

Steps to reproduce

Deploy they have these rules on : https://app.netlify.com/sites/asana-release/deploys/6287cf548f9bf400085c7ce2 Deploy URL to test on: https://6287cf548f9bf400085c7ce2--asana-release.netlify.app/guide/get-started/begin/quick-start

Rules in redirect: /%20 / 301 /%E2%80%8E / 301 /guide/* /fr/guide/:splat 301! Language=fr /guide/* /zh-tw/guide/:splat 301! Language=zh-tw /:path /de/:path 301! Language=de /:path /es/:path 301! Language=es /:path /fr/:path 301! Language=fr /:path /id/:path 301! Language=id /:path /it/:path 301! Language=it /:path /ja/:path 301! Language=ja /:path /ko/:path 301! Language=ko /:path /nl/:path 301! Language=nl /:path /pl/:path 301! Language=pl /:path /pt/:path 301! Language=pt /:path /ru/:path 301! Language=ru /:path /sv/:path 301! Language=sv /:path /zh-tw/:path 301! Language=zh-tw / /de 301! Language=de / /es 301! Language=es / /fr 301! Language=fr / /id 301! Language=id / /it 301! Language=it / /ja 301! Language=ja / /ko 301! Language=ko / /nl 301! Language=nl / /pl 301! Language=pl / /pt 301! Language=pt / /ru 301! Language=ru / /sv 301! Language=sv / /zh-tw 301! Language=zh-tw

Request used for testing: curl -L -I -H 'Accept-language: fr-FR' 'https://6287cf548f9bf400085c7ce2--asana-release.netlify.app/guide/get-started/begin/quick-start'

Sample screenshot showing the inconsistent response by Netlify. image (27)

There is also an open ticket with Runtime that is able to reproduce this behavior: https://github.com/netlify/pillar-runtime/issues/387#issuecomment-1139089522

A link to a reproduction repository

No response

Plugin version

@netlify/[email protected] from netlify.toml and package.json

More information about your build

  • [ ] I am building using the CLI
  • [X] I am building using file-based configuration (netlify.toml)

What OS are you using?

No response

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.

Builds logs (or link to your logs)

https://app.netlify.com/sites/asana-release/deploys/6287cf548f9bf400085c7ce2

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

bhavana-netlify avatar Jun 01 '22 19:06 bhavana-netlify

I believe that this is fixed by https://github.com/netlify/pillar-runtime/issues/387 @bhavana-netlify or are we waiting to hear back from the Enterprise customer still?

nickytonline avatar Jun 09 '22 19:06 nickytonline

Just following up on my previous comment @bhavana-netlify.

nickytonline avatar Jul 22 '22 20:07 nickytonline

I'm going to go ahead and close this @bhavana-netlify. If it's still an issue, feel free to reopen.

nickytonline avatar Oct 26 '22 13:10 nickytonline

I'm going to go ahead and close this @bhavana-netlify. If it's still an issue, feel free to reopen.

nickytonline avatar Oct 26 '22 13:10 nickytonline