vue-leaflet/Vue2Leaflet

token prop merged out

depperm opened this issue · 3 comments

Description

#32 added support for custom URL parameters (one I'm looking at specifically is token). #231 implemented mixins for props, but failed to implement/carry over token prop. I believe because of CORB issues having a CSRF token (see SE) would be a very useful feature to re-implement

Can token be re-added as prop (maybe in TileLayer mixin)

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Leaflet: v1.6.0
  • Vue: v2.6.10
  • Vue2Leaflet: v2.4.2 (earlier as well)
mikeu commented

Hi @depperm , is there a reason that passing the token as an option doesn't work for you? I think you should be able to use something along the lines of <LTileLayer :options="{ token: myTokenVal }"> to pass your value through to the constructor of the Leaflet TileLayer.

I'm also curious, I can't find token as a parameter in the Leaflet documentation, do you have a reference for where it's used, how it's defined, etc.?

that may work, I'll have to try that.

I didn't necessarily see token in Leaflet documentation, but seeing it in old vue-leaflet and reading about CSRF tokens I thought it was an added feature that fell by the wayside

mikeu commented

The change in #32 introduced the params prop to allow an arbitrary object to be passed to the Leaflet tileLayer constructor. For backwards compatibility with existing projects that had used :attribution and :token props, it left them as valid props and simply copied them into the params object before passing it on to Leaflet.

At that stage, there would have been no difference between <LTileLayer :token="myToken"> and <LTileLayer :options="{ token: myToken }">. Part of the refactor in #231 involved deprecating the former, but the latter is still supported and totally equivalent. So as far as I can tell, I don't think any change is needed here, unless you can confirm that there is a need to pass a token option to Leaflet, and that using the existing options object prop doesn't allow that—in which case, please do feel free to follow up and reopen this issue!