Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the http referer in javascript

Tags:

http

I have an image

<image src="blah.com/image.gif"/>
. when the image loads, is there a way to change the http referer to X so that the src host sees the http referer of the image request coming from X?
like image 361
user121196 Avatar asked Aug 12 '09 17:08

user121196


People also ask

How do I change http referer?

If you want to change the referer (url) header that will be sent to the server when a user clicks an anchor or iframe is opened, you can do it without any hacks. Simply do history. replaceState, you will change the url as it will appear in the browser bar and also the referer that will be send to the server.

Can you fake Referer?

Yes, the HTTP referer header can be spoofed. A common way to play with HTTP headers is to use a tool like cURL: Sending headers using cURL: How to send a header using a HTTP request through a curl call? can you provide some example code.

How do you set a referrer header?

It can be done by simply using the HTTP header or the meta element in HTML which takes referrer keyword as value that in turn allows referrer policy setting through markup or using the referrerpolicy content attribute in HTML.


1 Answers

It's not possible to change the referrer of an image request load but is possible to remove the referrer.

There is a cross browser solution in Javascript, it uses Iframes created dynamically, check a proof of concept ( disclaimer: It uses a little JS lib I coded for that purpose).

like image 142
jpgerek Avatar answered Sep 19 '22 11:09

jpgerek