Is there a way to intercept HTTP requests made by Craft and modify the headers? #16126
Unanswered
jamesmacwhite
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a Feed Me feed which provides image URLs on a CDN path, the issue is the CDN is using Cloudflare and our server environment which happens to be Craft Cloud is being caught Cloudflare's bot/fingerprinting detection and the image URLs when being attempted to be downloaded are getting a 403.
I've tested locally and found by specifying a User-Agent the request is successful. Unfortunately, for asset downloading in Feed Me there is no way to add/modify HTTP headers with Curl or fopen. I raised an issue on the Feed Me GitHub: craftcms/feed-me#1538
I was however wondering if there any way to use an event/app.web.php to intercept requests and add/modify headers depending on a condition i.e. hostname as a workaround. Feed Me I don't think provides any events specifically for asset fetching, so it's not really able to manipulate it, so I was wondering if I could do it somehow at the higher level.
Beta Was this translation helpful? Give feedback.
All reactions