简体   繁体   中英

how to pass url with headers to an img tag (src attribute)

how to pass an url to img tag with headers

<img src="url" /> 

I didn't try anything yet, I need some alternative solutions, work should be only javascript in front-end part

If you are talking about the security headers, or any other header of the request then browser will not allow you to do that, as headers are treated as unsafe parameter. If you need to download an image from the source where validation is required through headers then your option is to send a spearate ajax request with the security headers, there must be a param that allows include current website cookies as header and most probably it will handle the auth part on the server side. But actually your purpose it not clear, just sentting link with headers to img tag sounds already wrong. If you explain the main purpose maybe we can offer a solution.

PS The same question here have been answered here, if you google 'how to pass url with headers to an img tag' you will see link to stackoverflow as a first result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM