All my images on the server are protected and need an access token inside authentication header.
Do you have any idea how I get them into a Tile or as a background image?
- Can you ask the image provider not to require Auth header?
You made need to implement a custom fetch with Auth header:
async function fetchImage() {
try {
const response = await fetch("flowers.jpg");
if (!response.ok) {
throw new Error("Network response was not OK");
}
const myBlob = await response.blob();
myImage.src = URL.createObjectURL(myBlob);
} catch (error) {
console.error("There has been a problem with your fetch operation:", error);
}
}
You should be able to pass in the blob as a src to the image. LMK if this works
Thanks for the quick response.
Unfortunatelly removing the auth header is not an option.
But I will try your snipped.
Looks very promising.