Worker script not triggered for addresses with www prefix


I’ve been using a worker script for quite some time to create shortened URLs that will redirect to other pages on my site. Today, I discovered that all of these shortened URLs are returning a 404 error. The strange part is that once I reach the 404 page, if I remove the www prefix from the shortened address, the redirect works just fine. This has never been the case before, and I’m stumped.

All of my actual website pages (for example, work just fine with or without the www prefix. It appears as though the worker script is not running for any addresses with the www prefix.

Did you check that this is not a CORS problem ?
For me this sounds like a CORS Problem becouse when you remove the www prefix it works then !

1 Like

Thanks for this suggestion. Could this still potentially be the issue even though my worker script was working for nearly 2 years, and has now suddenly stopped?

Yes. As long you use your website with the www prefix and redirect to resources with the www prefix it works without problems.

When you are on your website without the www prefix and redirect to resources with the www prefix
it will be blocked. As you said removing the www prefix in such a scenario solves then the problem.

To amke it easy make sure that when a user use the website with the www prefix it load resources with the www prefix and when the user is using the website without the www prefix that you use the resources without the www prefix.

This is a security feature implemented by the Webbrowsers !

I apologize if I am misunderstanding you, and I greatly appreciate your help, but I don’t believe this is the problem. I haven’t altered my worker script and it worked for years up until today. I have page rules in place that redirect every page on my site to$1.

After running some more tests, it appears that when using the www prefix for any link to my website, my worker script is not being triggered. This explains why valid website pages work with or without the www prefix, while worker redirects do not.

The route I’m using is **, which if I understand correctly should match all routes. However, this does not work with the added www prefix for some reason. I’ve tried adding additional routes, but nothing seems to make this work correctly.

1 Like

any update on this
I have the same problem.

No update here. Still unable to find a good solution as of yet.

1 Like

i triggered the www and non www to the workers successfully but without any redirection :mask: and works well for me
Would you please try
and also this

I already have similar DNS and worker routes in place, but still am not getting my worker triggered with www.

could you please share your configuration
also i forget to mention the page rules

I use the Kajabi platform, and their documentation states that they require DNS records as follows:

And my worker routes:

Page rules:

you need to change www CNAME to A record you can see the images

delete regular expression on the worker routes

Made the changes and cleared cache, still not working.

it’s work for me

Please try vs

The problem is with pages that do not actually exist. This address redirects to another address through my worker script. It works fine without the www prefix. Any page that actually exists works with and without the www prefix, such as the homepage you tested.

Just an update on this issue. I was finally able to get this corrected by reaching out with Cloudflare logs to my SaaS provider (Kajabi), showing that there was a custom hostname change on 10/9/2020. As it turns out, they migrated their own DNS services to Cloudflare, which caused this strange issue. My worker script is once again being triggered at the edge as expected.