Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEOIP redirection causes 404 on specific cases #693

Closed
victoradobe opened this issue Apr 3, 2024 · 2 comments · Fixed by #694
Closed

GEOIP redirection causes 404 on specific cases #693

victoradobe opened this issue Apr 3, 2024 · 2 comments · Fixed by #694

Comments

@victoradobe
Copy link

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.

@ikhadka
Copy link

ikhadka commented Apr 4, 2024

@dpotkoc Please could you take a look at this.

Thanks
Ishwar

@dpotkoc
Copy link
Contributor

dpotkoc commented Apr 7, 2024

@victoradobe I reproduced issue. Tnx for reporting.

We are working on fix.

Domagoj

dpotkoc added a commit to favicode/fastly-magento2 that referenced this issue Apr 8, 2024
vvuksan added a commit that referenced this issue Apr 8, 2024
fix GEOIP redirection causes 404 #693
MickaelDatadome added a commit to DataDome/fastly-magento2 that referenced this issue Oct 24, 2024
* Update datacenters.json

* Added basename sanitize to original snippet name, preventing path traversal

* Bump to 1.2.208

* Update datacenters.json

* wp

* Update datacenters.json

* Bump to 1.2.209

* netacea integration v5.7.0

* Update datacenters.json

* Bump to 1.2.210

* Release notes update for 1.2.210

* Update datacenters.json

* php 8.3

* added opensearch

* fix for fastly#682

* fix for fastly#682

* Bump to 1.2.211

* fix fastly#682

* updating to DataDome Fastly Module 2.19.4

Signed-off-by: Mickaël Guichard <mickael.guichard@datadome.co>

* Bump to 1.2.212

* ci: Use GITHUB_OUTPUT envvar instead of set-output command

`save-state` and `set-output` commands used in GitHub Actions are deprecated and [GitHub recommends using environment files](https://github.blog/changelog/2023-07-24-github-actions-update-on-save-state-and-set-output-commands/).

This PR updates the usage of `::set-output` to `"$GITHUB_OUTPUT"`

Instructions for envvar usage from GitHub docs:

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter

* Module and documentation updates

* Documenation wording change

* Spelling fix

* Add support for Brotli static compression

* Add testing for 2.4.6 and PHP 8.3

* Bump to 1.2.213

* Rate limiting improvement

* fix code quality

* Bump to 1.2.214

* Netacea Magento module updated with additional logging

* Fix for checking if current IP is in maintenance IP list

* Bump to 1.2.215

* fix GEOIP redirection causes 404 fastly#693

* Bump to 1.2.216

* Bump to 1.2.217

* Netacea Magento module updated with PURGE requests handling

* Fixing deprecated usage - adding cast to string and tags size check

* Bump to 1.2.218

* Removing trailing comma in WAF constructor to be compatible with PHP 7.2

* Bump to 1.2.219

* Update datacenters.json

* Don't display API keys and tokens on endpoint update - they shouldn't be visible after configuration

* In 2.4 path is /pub/errors

* Bump to 1.2.220

* updating to DataDome Fastly Module 2.22.0

---------

Signed-off-by: Mickaël Guichard <mickael.guichard@datadome.co>
Co-authored-by: github-actions <vvuksan vvuksan@users.noreply.github.com>
Co-authored-by: ivanviduka <viduka.ivan@gmail.com>
Co-authored-by: Vladimir Vuksan <vvuksan@users.noreply.github.com>
Co-authored-by: Vladimir Vuksan <vlemp@vuksan.com>
Co-authored-by: Domagoj Potkoc <domagoj@favicode.net>
Co-authored-by: Richard Walkden <38424593+rswalkden@users.noreply.github.com>
Co-authored-by: Arun Sathiya <arun@arun.blog>
Co-authored-by: mizdebski-netacea <marek.izdebski@netacea.com>
Co-authored-by: Vladimir Vuksan <44271-vvuksan-fastly@users.noreply.drupalcode.org>
Co-authored-by: Marek Izdebski <103107299+mizdebski-netacea@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants