Você pode me dizer qual valor alterar na v2 beta 5 que fará com que o esri leaflet use JSONP por padrão em vez de CORS? <\/P>
<\/P>
Nosso setup SSO retorna um '302 found' ao usar as requisições CORS padrão. Se eu fizer a alteração abaixo, tudo funciona bem.<\/P>
https:\/\/github.com\/Esri\/esri-leaflet\/blob\/master\/src\/Support.js#L1<\/A><\/P> exportar<\/SPAN> var<\/SPAN> cors <\/SPAN>=<\/SPAN> ((<\/SPAN>window<\/SPAN>.<\/SPAN>XMLHttpRequest<\/SPAN> &&<\/SPAN> '<\/SPAN>withCredentials'<\/SPAN><\/SPAN> em<\/SPAN> novo<\/SPAN> window.XMLHttpRequest<\/SPAN>()));<\/SPAN><\/P> <\/P>exportar<\/SPAN> var<\/SPAN> cors <\/SPAN>=<\/SPAN> falso<\/SPAN>;<\/SPAN><\/P> <\/P>A documentação mostra que a forma antiga de desativar o CORS padrão é:<\/P>Se você não pode ou não quer habilitar CORS no seu servidor, o código a seguir fará com que todas as requisições utilizem JSONP.<\/SPAN><\/P>L.esri.get = L.esri.Request.get.JSONP;<\/SPAN><\/P> <\/P>Mas as notas de lançamento do Beta 2 dizem:<\/P>L.esri.Request<\/CODE> foi removido. Por favor, use L.esri.get<\/CODE>, L.esri.get.CORS<\/CODE>, L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
exportar<\/SPAN> var<\/SPAN> cors <\/SPAN>=<\/SPAN> ((<\/SPAN>window<\/SPAN>.<\/SPAN>XMLHttpRequest<\/SPAN> &&<\/SPAN> '<\/SPAN>withCredentials'<\/SPAN><\/SPAN> em<\/SPAN> novo<\/SPAN> window.XMLHttpRequest<\/SPAN>()));<\/SPAN><\/P> <\/P>exportar<\/SPAN> var<\/SPAN> cors <\/SPAN>=<\/SPAN> falso<\/SPAN>;<\/SPAN><\/P> <\/P>A documentação mostra que a forma antiga de desativar o CORS padrão é:<\/P>Se você não pode ou não quer habilitar CORS no seu servidor, o código a seguir fará com que todas as requisições utilizem JSONP.<\/SPAN><\/P>L.esri.get = L.esri.Request.get.JSONP;<\/SPAN><\/P> <\/P>Mas as notas de lançamento do Beta 2 dizem:<\/P>L.esri.Request<\/CODE> foi removido. Por favor, use L.esri.get<\/CODE>, L.esri.get.CORS<\/CODE>, L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.Request<\/CODE> foi removido. Por favor, use L.esri.get<\/CODE>, L.esri.get.CORS<\/CODE>, L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.get<\/CODE>, L.esri.get.CORS<\/CODE>, L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.get.CORS<\/CODE>, L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.get.JSONP<\/CODE>,L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.post<\/CODE> ou L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
L.esri.request<\/CODE> diretamente.<\/LI> <\/>\n< P> <\/>\nQual é a nova forma de fazer isso no beta 2?<\/>
Esri Leaflet only falls back onto JSONP when POSTing from a client browser that doesn't support CORS. if you'd like to trick our plugin into thinking that the end users browser doesn't support CORS, you can call...
L.esri.Support.cors = false;
Afterward, when calling L.esri.request(), JSONP will be used if its necessary to POST.
// to send a single JSONP ajax request L.esri.request('http://sampleserver6.arcgisonline.com/arcgis/rest/services/', { fakeParam: 'value that will push the request length past 2000 characters' }, function (error, response) { if (error) { console.log(error) } else { console.log(response) } })
If you need to POST across domains, please remember that it will be necessary to invoke a proxy.
we'll be updating the API reference soon, so i'll make sure the new information pertaining to L.esri.request() is as clear as possible.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.