Routing with workers

I have a worker routes that listen to example.com/api/*,
example.com
is hosted on pages. If I directly visit the api routes, it invoke the worker, but when I try to fetch /api/* endpoints in the page function, it will try to fetch from pages not workers. How do I solve this issue?
Was this page helpful?