Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide DynamicLayer with fetch options extension #1303

Open
syntax-punk opened this issue Dec 7, 2021 · 3 comments
Open

Provide DynamicLayer with fetch options extension #1303

syntax-punk opened this issue Dec 7, 2021 · 3 comments
Labels

Comments

@syntax-punk
Copy link

syntax-punk commented Dec 7, 2021

Describe the problem

In my current solution a MapService sits behind a proxy api which checks for JWT token provided as an "Authorization" header with each request before forwarding it further to the MapService. I cannot use "token" field of the DynamicLayer here since it simply attaches the token to the url as a query string it doesn't help much.

Describe the proposed solution

I would like to have an ability to either provide "extra" fetch headers to the DynamicLayer or initialize and provide the fetch client which the DynamicLayer can use to make API calls.

@jwasilgeo
Copy link
Contributor

@theVoogie have you considered writing your own network request interceptor as a first draft to see if it'll satisfy your use case?

Deeper down the requests coming out esri-leaflet are XMLHttpRequests and internally headers are set in these spots depending on the request type:

https://github.com/Esri/esri-leaflet/blob/master/src/Request.js#L94

https://github.com/Esri/esri-leaflet/blob/master/src/Request.js#L128

@syntax-punk
Copy link
Author

Hey @jwasilgeo , I haven't tried it yet and if it's good enough I'm ready to go. Can you suggest any 'good' examples I should follow?

@jwasilgeo
Copy link
Contributor

The idea of an interceptor came to my mind from other experience with the ArcGIS API for JavaScript and I believe several other 3rd-party request JS libraries also have such a concept. However, here you'd have to try to experiment and write it by hand, such as in the very first link above #1303 (comment). This was a blog post I found after some quick searching honestly. You may need to try it out globally in your code and see if you can intercept requests to your dynamic map server and add your own logic to apply custom headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants