Calling edge functions on route change in a Gatsby/SPA site

I’m trying to run an edge function on certain paths of a Gatsby site (shelter-website - england.shelter.org.uk). I have defined the function like this in netlify.toml:

[[edge_functions]]
  path = "/get_help"
  function = "test-webchat"

When running netlify dev or netlify serve locally the function works as expected, but only when navigating directly to /get_help. It is not called when following a link to get_help from the site’s nav (or any other link to it).

My assumption is that a route change in reach-router isn’t recognised as a page load. Is this correct?

Is this a limitation of edge functions or is there a way to work around this so that the edge function is called each time this route is loaded?

Thanks

Yes, because there’s either no request sent to server, or the request is sent to a different path. Most frameworks support client-side routing using JavaScript, so they either load a JSON file from a server (which is the different path scenario), or they load all the data at once (no request sent).

The workaround would be to alter your router to make a request every time a route is changed. For example, Vue router provides: Navigation Guards | Vue Router