Direct access to worker endpoints from the browser
How do i access the worker endpoints directly from the browser when using the vite plugin?
Setting the following doesn't solve it
Accessing
/api directly still shows the vite frontend.6 Replies
What comes immediately to mind is that
/api doesn't match /api/*. (Can you access things under /api like /api/foo?) If you want /api to work try using "/api*".Thanks for pointing out
/api*. i only had / under api route.
Now anything under /api is directly accessible through the browser(tried adding /health to the api route)what about subdomain routing based on hostnames in hono?
i tried accessing it through the terminal and this is what i get in the second image
The 3rd image is code for CdnMiddleware handler



You're returning the static asset. If the route you're hitting matches a static asset but you want the worker to respond you need
run_worker_first.i already use
run_worker_first for /api so care to explain how to proceed for dynamic cdn subdomains(cdnmiddleware was just a testing phase)? i have a handler for various subdomains for the main app.
setting run_worker_first to true gives me a 404 for the vite client
A route can match a static asset or not. If you want a route that matches a static asset to hit the worker, you need
run_worker_first. If you then decide that you don't want the worker to handle it, perhaps based on the hostname, you can hand back to the static asset handling with env.ASSETS.fetch().