Links problems
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
I have a file sharing app. Files that are uploaded are linked to your ownerId uuid. My problem is that i used to do this for fetching the file
But it was bad because you would not get any confirmation or feedback that the file is downloading so i moved to:
But i need to send the cookies with the request.
But because the api endpoint is different from the website. Chrome does not send it.
const clientId = await getClientId();
try {
const response = await fetch(url, {
method: "GET",
headers: {
ownerId: clientId,
},
});But it was bad because you would not get any confirmation or feedback that the file is downloading so i moved to:
<a
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/file/download/${data.id}`}
target="_blank"
rel="noopener noreferrer"
className="inline-block"
>
<Button
variant="default"
size="sm"
className="bg-gray-900 hover:bg-gray-700 text-white font-semibold shadow-md"
>
Descarcă
</Button>
</a>But i need to send the cookies with the request.
But because the api endpoint is different from the website. Chrome does not send it.
3 Replies
Torymid wasp
use fetch with
will assign the cookie header
credentials: 'include'will assign the cookie header
Cape lionOP
but the reason i moved to links was so the browser manages the download and not me ( the code)
i probably am going to add public one time use links that the client requests then uses to download the file something with an uuid