问题
I'm dynamically inserting the following tag into my webpage:
<img src="http://ia.media-imdb.com/images/M/MV5BMTgxMDczMTA5N15BMl5BanBnXkFtZTcwMzk1MzMzMw@@._V1_SX300.jpg">
When I go to the linked address, the image shows up fine. When I try to load it on my development server at http://localhost:8000, it shows up fine. But when I try to load it on my production server at http://example.org, it doesn't show up, and the console shows "Failed to load resource: the server responded with a status of 403 (Forbidden)"
Here's the javascript that inserts the tag:
$("#sb-photo").html('<img src="' + movie.Poster + '">');
UPDATE: This older question seems to address the same problem:
Getting 403 forbidden when dynamically loading images in AngularJS
However, the accepted answer doesn't actually work, at least not anymore.
Also, I just realized that the first time I insert an image, it works. But following times I get the 403 error.
来源:https://stackoverflow.com/questions/37231735/i-get-a-403-error-when-inserting-an-image-tag-into-my-website