This is very odd and I have already google it for one day but no good answer. Let's make it clear:
I have a local running web application. I can view it by http://localhost
or http://www.mylocalhost.com
(Both localhost and www.mylocalhost.com is specified in the hosts file which points to 127.0.0.1).
There is a <img>
tag in this local application's page : <img src="http://mycompany.com/files/abcdefg.jpg" alt="abcdefg" />
. I want to display a image at this page. This image is provided by mycompany.com
which requires authenticated access. I confirmed I have logined for mycompany.com
, and I definitely found the authenticated cookie in my browser for mycompany.com
, and I can get the image directly by this link http://mycompany.com/files/abcdefg.jpg
.
However, when I try to display this image file by the local web application's page, it always failed cause the browser does not set the cookie for the image request. I check this in the browser's debug console. (ordinarily can be activated by F12
) In fact, the request has no cookie.
More strange is that when I put this web application on our test server(another computer), everything turns okay. It seems this problem only occurs locally.
I have tried this over and over again. Even I changed the domain name in the hosts file, it still not work. And it's not also the Chrome's problem, Edge and Firefox do the same behavior.
I almost realize that probably is a W3C rule but I still did not found it.
Aucun commentaire:
Enregistrer un commentaire