ol-mapbox-style icon indicating copy to clipboard operation
ol-mapbox-style copied to clipboard

CORS - Credential issue

Open sylvainbeo opened this issue 5 years ago • 4 comments

Hi,

I saw that 'same-origin' is used for the credentials when fetching the style. Shouldn't this be parametrable ? So we could call olms giving that parameter.

In my case, i need to set "include", but i cannot.

What do you think ?

Thank you for the work.

sylvainbeo avatar Oct 20 '19 14:10 sylvainbeo

For the style, you can pass an object instead of a url. Then you could do something like

fetch(styleUrl, {credentials: 'include'}).then(response => {
  response.json().then(style => {
    olms('map', style);
  });
});

ahocevar avatar Oct 20 '19 15:10 ahocevar

@ahocevar I don't think it will work, because "same-origin" is also hard coded in the applyStyle function. And that one cannot be avoided i think.

sylvainbeo avatar Oct 21 '19 08:10 sylvainbeo

We could either expose a global fetch options object, or you could use a fetch wrapper as additional entry point in your webpack config. If you prefer the former, we'd appreciate a pull request.

ahocevar avatar Oct 21 '19 08:10 ahocevar

@ahocevar For the moment, i found a solution just by configuring my nginx in a better way. But i keep that ticket in mind. Thank you for you time.

sylvainbeo avatar Oct 23 '19 08:10 sylvainbeo