in my React-based web application I need to send images (mostly, but also other files) to the clients via a Laravel-based REST API. Because these images are send relatively often, I want to cache them. What gives me headaches is that the images need to be restricted to registered users only. (oAuth is used for authentication)
I thought about two different approaches, but have the feeling that I miss the forest for the trees:
- Send the binary data and store it in the local storage. Would work, but I would have to implement cache handling myself.
- Instead of sending the binary data, just send a link to the resource, so the browser takes care of the caching. But here is the question, how to restrict the access? The browser would just send a GET request, so no authentication token is included in the Header. I guess I could use a Cookie, that is set after successfully authenticating in the web application and is only used for telling the web application that the user is allowed to view the images. But, to be honest, this feels like a really wonky solution.
So, I‘m a little lost here and I would be really happy if someone can give me a push in the right direction. Thanks for your time and help!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire