App for Cloudflare® Pro

App for Cloudflare® Pro 1.9.9

  • Item seller Item seller Shawn
  • Featured

App incorrectly assumes site running on domain root

Simon

New member
I've noticed that the application seems to assume that the site is hosted on the domain root (example.com) rather than using a subdomain (www.example.com)

As such, when enabling R2 for media on a subdomain, the suggested domain is media.www.example.com

This isn't really a problem - I spotted it and changed it before continuing.

However, when disabling R2 for media when testing something, then re-enabling it, it defaulted back to media.www.example.com which I didn't immediately pick up and so ended up having to clean up the extra sub-subdomain created in my DNS and R2 configuration.

Can I suggest that:
  1. if the site uses the www subdomain, you default to dropping www before adding media to the front, and
  2. you somehow store the media domain chosen when initially enabled, and use that stored value as the domain when re-enabling R2 to ensure consistency
... particularly if someone decides to use a subdomain other than media, it would be useful to default to their choice when disabling / re-enabling R2
 
I've noticed that the application seems to assume that the site is hosted on the domain root (example.com) rather than using a subdomain (www.example.com)

As such, when enabling R2 for media on a subdomain, the suggested domain is media.www.example.com
Wouldn't that be the opposite? It knows it's *not* on the domain root, so it doesn't do things as if it was. It doesn't add www to the suggested R2 domain, it takes what the site is already using and prefixes it with media., but it's only that... just a default, you of course can pick anything you want. If you drop www automatically, you start running into other issues that are more problematic than choosing the public domain you want manually once when you enable it (for example, let's say you have different sites on different subdomains... Let's say you had these different sites:
  • www.example.com
  • www2.example.com
  • web.example.com
  • example.com
  • somethingelse.example.com
Dropping the first level subdomain would result in all of them defaulting to the same public domain for different buckets (which will fail when the public domain is assigned because you can't assign the same media.example.com DNS record to multiple bucket).

This isn't really a problem - I spotted it and changed it before continuing.

However, when disabling R2 for media when testing something, then re-enabling it, it defaulted back to media.www.example.com which I didn't immediately pick up and so ended up having to clean up the extra sub-subdomain created in my DNS and R2 configuration.

Can I suggest that:
  1. if the site uses the www subdomain, you default to dropping www before adding media to the front, and
See above. example.com and www.example.com are in some cases different sites (while most don't use them for different sites, some do)... so arbitrarily dropping one specific subdomain while not dropping others to save someone from needing to pick their own public domain once when it's enabled is really just going to cause more issues than it solves. If it's *really* that important to you, could maybe do a flag you add to your wp-config.php file, but honestly it seems like adding something to the config file is going to be more time than choosing the public domain you want (again, normally it's done once, and that's it).

  1. you somehow store the media domain chosen when initially enabled, and use that stored value as the domain when re-enabling R2 to ensure consistency
... particularly if someone decides to use a subdomain other than media, it would be useful to default to their choice when disabling / re-enabling R2
The cleanest way would be to read public domains already set for an existing bucket, but there are potential issues with that as well. What if the bucket has multiple public domains assigned to it? If the plugin is used in a multisite network, there's already functionality to assign an infinite number of public domains to a single bucket (for when all sites in the network share a single bucket).

Other than for testing, is there a reason I'm not thinking of where people would be enabling and disabling repeatedly?
 
Wouldn't that be the opposite? It knows it's *not* on the domain root, so it doesn't do things as if it was. It doesn't add www to the suggested R2 domain, it takes what the site is already using and prefixes it with media., but it's only that... just a default, you of course can pick anything you want. If you drop www automatically, you start running into other issues that are more problematic than choosing the public domain you want manually once when you enable it (for example, let's say you have different sites on different subdomains... Let's say you had these different sites:
  • www.example.com
  • www2.example.com
  • web.example.com
  • example.com
  • somethingelse.example.com
Dropping the first level subdomain would result in all of them defaulting to the same public domain for different buckets (which will fail when the public domain is assigned because you can't assign the same media.example.com DNS record to multiple bucket).

The vast majority of websites will either use the domain root, or add www - and indeed the endless arguments online about whether to use the root or www is evidence of exactly that.

I think it's pretty safe to assume that:
  1. www is extremely common, and
  2. www is almost never going to want to be included in the subdomain if you arbitrarily add a prefix
I would have thought it would be pretty simple logic to check for www and only www and drop it for the suggested subdomain - while not making assumptions about any other subdomain.

So based on your examples, my suggestion is to do the following in your suggested media domain:
  • www.example.com => media.example.com (this is the only one that matters)
  • www2.example.com => media.www2.example.com (because I think it's safe to assume that someone using www2 knows what they are doing and we don't want to make further assumptions)
  • web.example.com => media.web.example.com (again, don't make assumptions)
  • example.com => media.example.com
  • somethingelse.example.com => media.somethingelse.example.com (not making assumptions)
... it's only the very specific www subdomain that should be dropped in my opinion because you cannot assume anything else other than the simple fact that www vs non-www is the most common scenario and also the most likely to cause issues. Anyone using any other subdomain, including www2, or geo-specific subdomains like www-au (looking at you, Computershare 🙄 ) is likely doing something more complicated and so you don't want to make any assumptions at all.

example.com and www.example.com are in some cases different sites (while most don't use them for different sites, some do)... so arbitrarily dropping one specific subdomain while not dropping others to save someone from needing to pick their own public domain once when it's enabled is really just going to cause more issues than it solves.

I think having www.example.com and example.com as different sites is potentially the most unlikely scenario of any, statistically speaking - while I don't assert that it never happens - I've never seen it personally myself, it's extremely uncommon. However, having www but not wanting to use media.www.example.com is arguably far more likely to happen, in my opinion and experience.

The cleanest way would be to read public domains already set for an existing bucket, but there are potential issues with that as well. What if the bucket has multiple public domains assigned to it? If the plugin is used in a multisite network, there's already functionality to assign an infinite number of public domains to a single bucket (for when all sites in the network share a single bucket).

Other than for testing, is there a reason I'm not thinking of where people would be enabling and disabling repeatedly?

Yes, it's not going to be a common issue, but I was caught out by it, so it is an actual issue - even if uncommon. Either way, I think the number of people who inadvertantly end up with media.www.example.com and then might not know how to fix it - could be avoided with this fairly simple change.

Perhaps if you check the public domain already set on the bucket and if there is only one, default to that - but if there are none or more than one, use your existing logic (including perhaps dropping www if it exists?) and don't make any further assumptions?

Anyway - it's just a suggestion that I thought might help the UX a little for some more inexperienced users - not a big deal either way.
 
Back
Top