tomcat – How to solve CORS problems between OpenLayers v6.14.1 and GeoServer 2.20.2 in Reactjs?

I’m trying to get WMS layer as a tile layer via “tileLoadFunction” in OL v6.14.1 in reactjs but when I run below code I will get CORS error message: map.addLayer( new TileLayer({ source:new TileWMS({ url:`http://194.105.111.10:8080/geoserver/${selectedLayer[i].datastore}/wms`, visible:true, projection:’EPSG:4326′, params:{‘LAYERS’:layerName,’TILED’: true}, serverType:’geoserver’, tileLoadFunction:function(image, src) { var xhr = new XMLHttpRequest(); xhr.responseType=”blob”; xhr.open(‘GET’, src); xhr.setRequestHeader(“Access-Control-Allow-Origin”,”http://194.105.111.10:3000″) xhr.setRequestHeader(‘Authorization’, ‘Bearer f5711f9d-aa2d-4067-p5a9-af913vd16a21’); … Read more