(Bug) Why is my frontend code being executed from another unknown machine based in another country?

I’m adding GitHub user authentication to my website, which involves redirecting the user to GitHub, where, after approving the app, they are redirected back to my site with a code in the URL. Using this code I can then generate a secure, secret access token for them.

I’ve tried two different approaches and run into the same issue with both.

In my first attempt, I exposed a Wix HTTP function that I would pass the GitHub code to from my client-side code , but I found that whenever I did so it would inexplicably trigger the backend code two or three times. This is problematic because the GitHub code is only valid for one use, and so my function would succeed on the first call, but then fail the second and third time, returning a failed result.

Upon inspection, the incoming requests revealed some key differences; they are clearly coming from multiple machines. These are two of the three requests my function received after I sent a single HTTP request to it from the client-side:


Note the difference in IP and Country Codes.

I couldn’t find a way around this, so I changed my approach to the one suggested for this kind of thing: using Wix routers. But after spending some time refactoring my code, I’ve run into exactly the same problem again, and this time, after a closer look, I noticed that when I hit the page it runs my client-side code once in the browser and once on another, unknown machine. I know this because I’ve set up some temporary webhooks that data is posted to when the code is hit.

And as you can imagine, my backend code is triggered multiple times, putting me in exactly the same predicament as before.

Here’s my router code

and the client-side page code

Chrome dev tools - running once, as expected

Webhooks used for debugging

This doesn’t seem like expected behaviour to me. Why is another, unknown machine based in another country executing my client-side JavaScript? Surely it should only run in my browser?

Can anyone confirm if this is a known bug? I suspect the frontend code being triggered twice here is also responsible for the issues I ran into with my first approach.

I would appreciate it if someone could shed any light on this because I would be sad if I had to abandon my build.