So I need cdn.ex.com/avatars/:UserID
point to my cloud public file URI which is https://cloudapi.com/account.cloud.com/files/uploads/avatars/(userid)/avatar.png
(true URL is put)
I don't have any code yet except
app.get('/avatars/:userid', (req, res)=>{
let userid = req.params.userid
let uri = `https://cloudapi.com/account.cloud.com/files/uploads/avatars/${userid}/avatar.png`
});
So I shall be able to do in html:
<span>Username</span>
<img class="pfp" src="cdn.ex.com/avatars/671856275627525">
Instead of having to do
<span>Username</span>
<img class="pfp" src="https://cloudapi.com/account.cloud.com/files/uploads/avatars/671856275627525/avatar.png">
Any help on how can I do that?
I found it,
You use node-fetch to fetch the resource
Then send data as buffer
If its used in tag it will work, if a user tried going to the link it will work too.
Goto google and search node-fetch then goto its npm and search for Buffer
Then just res.send(buffer) instead of fileType(buffer)
and remove the last line.
Thanks for @Marc for trying to help (in comments)