Home > Software engineering >  <img src: <call and then call again>/>
<img src: <call and then call again>/>

Time:11-24

Hei there! I have a bunch of images in a google bucket, identified by id's I also have a rest API that can be called with an id query parameter like so

GET: /give_image_pls?id=619e0dd124122some10190cdbdb9
RESPONSE: https://storage.googleapis.com/619e0dd12412210190cdbdb9.png

This is because the server creates a URL that's valid for a few seconds

Is there any way, frontend or backend, that I could do

<html>
  <img src=/give_image_pls?id=619e0dd12412210190cdbdb9/>
</html>

in such a way that the src property would request the URL and then request the response URL to finally display the image?

I have tried setting 30[0..9] status codes in the give_image_pls response, that did not do the trick

CodePudding user response:

The server should return a 302 Found response code with the new URL in the Location HTTP response header; this way the browser will transparently make another request to that URL.

  •  Tags:  
  • html
  • Related