Repository navigation
feat: custom request headers and fetch (0.3.0) - #7
Merged
Merged
Conversation
- headers option (object or per-request function) merged into every widget request; content-type, authorization and the gateway credential headers cannot be overridden - fetch option replaces globalThis.fetch for all widget requests - both available via configure(), element properties, and React/Vue props - reuse visitor sessions until 10% of the token lifetime remains (capped at 24 h) instead of a fixed 24 h - bump to 0.3.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
For backends behind a same-origin BFF that needs a CSRF header on POSTs.
headers?: RequestHeadersOption(Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>)), evaluated before every request (config, session, history, chat), so a rotating CSRF token works.content-type,authorization,x-dewee-gateway-urlandx-dewee-gateway-tokencannot be overridden (case-insensitive; dropped).fetch?: typeof fetchused for every widget request (defaultglobalThis.fetch).configure(),el.headers/el.fetchproperties (no attributes), React props and Vue props, and changes apply on the next request without remounting.RequestHeadersOptionandRESERVED_HEADERSare exported.docs/http-contract.md"Extra request headers". Cross-origin backends must allow extra headers in CORS preflight (built-in handlers allow only their own).Tests
test/request-headers.test.ts: merge order and per-request evaluation, reserved-header protection, default/global and custom fetch, short and long session TTL reuse, elementconfigure()and property updates.