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

Incorrect behaviour of "dev --country" command #4819

Closed
MarcL opened this issue Jul 18, 2022 · 0 comments · Fixed by #4821
Closed

Incorrect behaviour of "dev --country" command #4819

MarcL opened this issue Jul 18, 2022 · 0 comments · Fixed by #4821
Labels
type: bug code to address defects in shipped code

Comments

@MarcL
Copy link
Contributor

MarcL commented Jul 18, 2022

Describe the bug

When using ntl dev --country=<2-letter-iso-code> it fails to set geo=mock as suggested in the documentation.

country (string) - Two-letter country code (ISO 3166-1 alpha-2, https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) to use as mock geolocation (enables --geo=mock automatically)

Instead it reads the cached or real version of the country code if it exists.

Steps to reproduce

This was reproduced with the Astro starter kit.

  1. Clone the repository git clone git@github.com:sarahetter/astro-netlify-edge-starter.git
  2. Install dependencies: npm install

Incorrect behaviour

  1. Start the dev server using ntl dev --country=AU to choose Australia as the country code
  2. Observe the page at http://localhost:8888 - the message displayed will be "Welcome, visitor from United Kingdom!" (this will be shown as your own country name instead of "United Kingdom")
  3. This is incorrect behaviour as the geolocation has not been mocked with the Australia country code
  4. Using console.log(context); to log the edge function context shows my UK-based geolocation:
  geo: {
    city: "Warrington",
    country: { code: "GB", name: "United Kingdom" },
    subdivision: { code: "ENG", name: "England" }
  }

Correct behaviour by adding the geo command

  1. Start the dev server using ntl dev --country=AU --geo=mock to choose Australia as the country code AND to enable geolocation mocking
  2. Observe the page at http://localhost:8888 - the message displayed will be "Welcome, visitor from Mock Country!"
  3. Using console.log(context); to log the edge function context now shows:
  geo: {
    city: "Mock City",
    country: { code: "AU", name: "Mock Country" },
    subdivision: { code: "SD", name: "Mock Subdivision" }
  }

Configuration

[build]
command = "npm run build"
publish = "dist/"


[[edge_functions]]
path = "/"
function = "geolocation"

Environment

  System:
    OS: macOS 12.4
    CPU: (10) x64 Apple M1 Pro
    Memory: 267.52 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v14.19.3/bin/yarn
    npm: 6.14.17 - ~/.nvm/versions/node/v14.19.3/bin/npm
  npmGlobalPackages:
    netlify-cli: 10.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant