The important thing to note is that I have already set the Origin Path to "/media" in the AWS CloudFront management panel.
Therefore, in the Magento CDN configuration, I should not include the "media" path when setting up the media URL.
In other words, I should only set the pure domain name as follows:
https://d3dxxxxxxg.cloudfront.net/
When making a request like the one below from webbrowser to AWS CloudFront:
AWS CloudFront will automatically append the origin path (/media) that I have configured to the request when reaching out to the my origin server:
https://<Origin My Server>/media/catalog/product/cache/0b92992ca6366f8cb05593cfbb60c917/s/e/seventeen-going-magazine-vol-rn-0.jpg
In Magento, the media path can vary depending on Magento's configuration (Secure Base URL for User Media Files).
If the following code is checking the captcha directory within the media path, comparing it as a constant value could potentially be a source of errors.
It would be better to dynamically retrieve the currently configured Magento media directory or URL using a function from the Magento core or its equivalent (getMediaUrl()) function and then compare it.
AWS CloudFront CDN Domain Name
https://d3dxxxxxxg.cloudfront.net/
AWS CloudFront CDN Setting - Origin Path
Magento's CDN Setting
I am currently operating a website with the above configuration. In the Magento frontend HTML, the image URL is represented as follows:
The important thing to note is that I have already set the Origin Path to "/media" in the AWS CloudFront management panel.
Therefore, in the Magento CDN configuration, I should not include the "media" path when setting up the media URL. In other words, I should only set the pure domain name as follows:
When making a request like the one below from webbrowser to AWS CloudFront:
AWS CloudFront will automatically append the origin path (/media) that I have configured to the request when reaching out to the my origin server:
In Magento, the media path can vary depending on Magento's configuration (Secure Base URL for User Media Files). If the following code is checking the captcha directory within the media path, comparing it as a constant value could potentially be a source of errors.
https://github.com/yireo/Yireo_NextGenImages/blob/c1f26f7f9fcc0cb949fa55a18a730ad5caf97b0a/Util/HtmlReplacer.php#L249
It would be better to dynamically retrieve the currently configured Magento media directory or URL using a function from the Magento core or its equivalent (getMediaUrl()) function and then compare it.