cloudinary_npm
cloudinary_npm copied to clipboard
How to generate `https` URL with custom cname?
Cloudinary.url ignores option cname, unless option secure is passed with value false, in which case it generates an http URL
Example:
expect(
Cloudinary.url('sample', { cloud_name: 'xyz', cname: 'static.example.com' })
).to.equal(
"https://static.example.com/xyz/image/upload/sample"
) // fails
expect(
Cloudinary.url('sample', { cloud_name: 'xyz', cname: 'static.example.com', secure: false })
).to.equal(
"http://static.example.com/xyz/image/upload/sample"
) // passes
// Other expectations:
expect(
Cloudinary.url('sample', { cloud_name: 'xyz', cname: 'static.example.com', private_cdn: true })
).to.equal(
"https://static.example.com/image/upload/sample"
)
Might need to change this condition: https://github.com/cloudinary/cloudinary_npm/blame/master/lib/utils/index.js#L928
If you have a cname that is defined through us then to generate a secure URL with your domain should be defined as the following
expect(
Cloudinary.url('sample', { cloud_name: 'xyz', secure: true, secure_distribution: <cname>})
).to.equal(
"https://static.example.com/xyz/image/upload/sample"
)
Nice! I had missed the secure_distribution option, but I found it in docs after searching. Closing the issue