-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add a "headers" option to IRequestOptions #436
Conversation
…ass on the headers to the reque add a "headers" option to IRequestOptions. Optional headers are passed on to the request. When headers option is present in Node environments, it prevents the default referer header "@esri/arcgis-rest" from being set on the request. AFFECTS PACKAGES: @esri/arcgis-rest-request
if (typeof window === "undefined") { | ||
if ( | ||
typeof window === "undefined" && | ||
requestOptions.headers === undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we set the referrer when headers are passed-in but referer is still undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, that's prob a good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks, Rich!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've proposed a few small tweaks in #437
Closing this, now covered in #437 |
thanks for this contribution @rgwozdz 🌮:tada:! |
This PR does the following
adds a
headers
option to IRequestOptions. Optional headers are passed on to the target request.in Node environments, the presence of the
headers
options prevents the defaultreferer
header"@esri/arcgis-rest"
from being set on the request. If areferer
is desired, it can be set with the header option.I have found that (2) is critical in a particular case; ArcGIS search service sometimes rejects a request with a valid token when the
referer
is set to"@esri/arcgis-rest"
. (Note that in such cases, ArcGIS search returns a498 Invalid token
response; but stripping the referer header from the request results in a success response, which indicates the problem is not with the token.)