Alright, so I removed the custom domain from under the trigger section, and then added the route and zone to the routes section just below it like this: domain.com/folder/path* with an asterisk at the end to deal with any parameters passed. Now when I attempt to hit that endpoint with or without params it says site can’t be reached.
I’m just trying to make it so that when somebody visits mydomain.com/matchedpath?param1=value1 it triggers a specific worker and when somebody visits mydomain.com/matchedpath2?param1=value1 it triggers another, and when somebody visits just mydomain.com they are returned a 404 or served a not found, that’s all.
Right, I figured this was the case, however when I removed custom domains from this section here ALL routes broke and, when i add it back in, visiting the root domain will trigger a worker when it should do nothing. Shown here because i can’t add images for some reason https://ibb.co/xzB38qD
krakentrk.com/tp/ma* should run a specific service worker for that path.
I just added the custom domain back, so if you visit that path above (or any other path on the domain, because a custom domain seems to make paths useless) it will run the worker and redirect you to an end site.
If you add a custom domain it will capture all paths, parameters, etc. If you only want it to run on a specific route or specific routes, remove the custom domain and only add the routes.
I know it works. I’ve done it. I cannot guess why it doesn’t work for you because I cannot see the complete setup of your account and worker.
You’ll likely run into caching issues because you are using 301 Moved Permenantly rather than a 302 Found or 307 Temporary Redirect. This could explain why the root domain continues to redirect after you removed it.
The code, while working, isn’t efficient as there are duplication of new URL(request.url) and unused variables.