fastly / fastly-magento2

Module for integrating Fastly CDN with Magento 2 installations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GEOIP redirection causes 404 on specific cases

victoradobe opened this issue · comments

The GeoIP redirect functionality redirects customers to a specific store based on his Geolocation. The problem is that sometimes, the customer is redirected to a page that doesn't exist if the url contains the "store_code" but doesn't have a "/" in the end.

Pre-requisites to reproduce:

  1. Clean Magento instance with at least 2 store views
    1.1 Example: I'm using 2 store views (en and fr)
    image
  2. Configure store to add store codes to the url (Stores -> Configuration -> General -> Web -> Url Options -> Add Store Code to URLS):
    image
  3. Configure Fastly (Stores -> Configuration -> Advanced -> System -> Full Page Cache -> Caching Application):
    image
  4. Configure GeoIP redirect (Stores -> Configuration -> Advanced -> System -> Full Page Cache -> Caching Application -> Fastly Configuration -> Advanced Configuration -> GeoIP Country Mapping):
    image

Steps to reproduce:

  1. On a incognito tab, access the store front using a code that is not from your geolocation
    1.1 Ex: You're from EN, access the other storeview https://store-test.com/fr/
  2. You'll see the dialog to tell about the redirection
  3. Now, close all incognito tabs and open a new one
    3.1 Access the other storeview again, but now remove the last "/": https://store-test.com/fr

Expected Results

Customer is redirected to the other storeview and sees the homepage

Actual results

Customer will be redirected to the other store but the url will be something like:
https://store-test.com/en/en instead of just https://store-test.com/en/ (notice the extra "en" code)

Additional info

It seems that the error originates on Fastly\Cdn\Block\GeoIp class:
Screenshot 2024-04-03 at 15 14 22

Maybe a check could be done to add an extra "/" to end of the url if there isn't one, or remove all paths completely.

@dpotkoc Please could you take a look at this.

Thanks
Ishwar

@victoradobe I reproduced issue. Tnx for reporting.

We are working on fix.

Domagoj