#Specifying a method for a worker route

3 messages · Page 1 of 1 (latest)

exotic shuttle
#

Hello!

I am using workers to run a specific script for a specific method at a given route (for example website.com/specific-route).

In order to to this I currently run this check in the worker:

if (request.method !== "POST") {
  return Response.json("", { status: 405 });
}

However I am worried that even when called with a GET for example, this will still count as a worker invokation for billing purposes. Is there a way to restrict a worker route for a specific method?

blissful lichen
#

It's $0.30 per million requests though, ~333+ million requests for $100 dollars (excluding cpu time, but would be very tiny if the first thing it does is check that and return), even assuming ddos protection/etc doesn't kick in, Workers are pretty cheap