I am encountering an error when referencing an image, hosted on one of my websites, from another one.
Problem
- Image is hosted on https://example1.com
- Trying to reference image from https://example2.com by placing src=“https://exmaple1.com/imaginaryPath/guest.png” in an element.
- Image doesn’t appear. Console returns “Access to image at ‘https://example1.com/imaginaryPath/guest.png’ from 'EX.AM.PL.E/IP” origin “https://example2.com/” has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource."
.htaccess on https://example1.com/
(yes the root site directory, not a subdirectory.)
Header set Access-Control-Allow-Origin "\*"
Header set Access-Control-Allow-Methods "GET"
Yes, httpd (Apache) reads the .htaccess per the rules in the .conf
Please help
Tried:
- Modifying Apache Configuration
- Modifying Method of Referencing Image
Expected:
- Image to Load
- No Related Console Errors
EDIT:
The code provided is for the HTML image element. The CORS Policy errors are no longer occurring, but the image still does not appear. Additionally, the image, from the same exact URL, does load when simply navigating to it through a browser.
Code (image):
<img src="https://example1.com/imaginaryPath/guest.png" alt="Guest">