Allowing requests to Worker only from Pages


I have a service deployed and built an UI for it using Pages. Now, I wanted some authentication in between, so I changed this and also created a Worker that is in-between. So now everything looks like this: Pages → Worker → 3rd party service
There is the authentication between the worker and the 3rd party service, but I can’t seem to find how to do something between Pages and Worker. I would like to only allow that specific Website to make requests to the worker, if possible. How could one achieve this?

Thank you

As I understand it, you cannot put a worker in front of a pages deploy.

Instead, use Pages Functions which are built into a worker. If you are using this for authentication you might wish to build Middleware as they will run before other functions.

1 Like

The problem I’m having with that is that even if I put a folder called functions at the root of the zip file, when deploying the Pages, the functions are not created

Of course not. They need building. If you want to use functions, you will need to deploy the project from git, or use wrangler.

1 Like