Closed Macklawe closed 2 years ago
What form does your token have? URL parameter or HTTP header?
As http header
Check https://mmomtchev.github.io/rlayers/#/addon for how to extend rlayers
Create your own layer class extending from RLayerTile
and overload only this function:
class AuthLayerTile extends RLayerTile {
createSource(): void {
this.source = new XYZ({
url: this.props.url,
projection: this.props.projection,
tileGrid: this.props.tileGrid,
tileLoadFunction: <your_tile_load_function>
});
this.eventSources = [this.ol, this.source];
}
Also check this stackoverflow answer which, even if it is a bit old, still works: https://stackoverflow.com/questions/49095151/how-to-add-a-http-header-to-openlayers4-requests
These days you can use the fetch
API which is better.
Thanks a lot. It works
Hi, I try to load tile from a server, and i recieve error, because my request is without correct token. How can i provide axios or token to request?
![error](https://user-images.githubusercontent.com/13092541/160630514-61621d58-72e2-49c6-ab41-f0b2536c1772.png)