Hi,
I’ve been using Pages for hosting a static Eleventy website, and so far it’s been great.
Yesterday, I added a Pages Function that subscribes people to my newsletter if they fill in a form.
However, so far today, the function has been invoked 10.000 times. Which is impossible given that my website receives only 2000 visits per day and not every visitor signs up for my newsletter.
At first, I thought this was caused by bots. So I tried:
-
Adding a Page Rule that increases the security level to high. That didn’t have any impact, the request counter kept increasing.
-
As no logging is available for Pages Functions, I added some logging myself. Every time the Function is invoked, I send the
request
object to New Relic. This reveals almost no requests (only test requests that I make).
So my question is: what is causing these “ghost” requests to my Function? At this rate, I’ll blow through half of the free-tier everyday.
The function is stored in this path in my git repo: functions/newsletter/signup.js
Which means it’s accessible through this URL: https://savjee.be/newsletter/signup
The function itself only processes POST
requests:
export async function onRequestPost({request, env})
{
// 1. Log request to New Relic with "fetch"
// 2. Call the newsletter API to add a subscriber
}
The full code of my function is available here: savjee.be/signup.js at master · Savjee/savjee.be · GitHub
(Yes, I realise my API token for New Relic is exposed, but it’s for testing purposes only).
My previous newsletter are also posted on the website and have this URL format: /newsletter/issue/18/
I initially thought that the Function might be wrongly triggered because it’s shares part of the URL. However, these pages don’t get much traffic, and again, I’m not seeing anything come up in New Relic.
Any thoughts? I must be missing something obvious.