Using secure(true).cdnSubdomain(true) causes NullPointerException if secureDistribution is not set in configuration
martron opened this issue · 2 comments
Trying to use both https AND multiple CDN subdomains resulted in a NullPointerException. Using either configuration on their own worked fine but always caused an exception when used together.
I tracked the issue down to this line:
secureDistribution = this.config.secureDistribution.replace("res.cloudinary.com", "res-" + shard(source) + ".cloudinary.com");
It's trying to run .replace() on this.config.secureDistribution but this.config.secureDistribution is null because I never set it in the configuration (I don't have a private subdomain).
My workaround was to add a secureDistribution = "res.cloudinary.com" to my configuration. This works fine but it was a non-obvious fix.
Hi @martron, In general, domain sharding is not a best practice anymore, especially not on HTTPS (where each connection requires asking for an SSL certificate). With HTTP/2, which Cloudinary supports by default when using HTTPS, domain sharding is unnecessary and it can actually do more harm than good.
With that said, I'm checking this issue internally and will update here shortly.
Hi @martron, I apologise for the delayed update. We currently do not support generating HTTPS URLs with domain sharding. As mentioned in my last response, Cloudinary support domain sharding by default when using HTTPS (With HTTP/2), so this is actually unnecessary. I'll close this ticket now, but please feel free to re-open it if you have any further concerns regarding this matter.