feat: Add optional Accept-Language header configuration #1148
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.
Changes
This change introduces an optional configuration setting,
acceptLanguage
, allowing developers to specify preferred language tags (e.g., "en-US", "fr-CA,fr;q=0.9") during SDK initialization. When provided, the SDK will automatically include theAccept-Language
HTTP header with the specified value in all outgoing API requests.Usage Summary:
Developers can now optionally provide an
acceptLanguage
string when initializing the SDK either via theAuth0
class constructor or theAuth0Provider
component prop.If provided, the
Accept-Language
header will be automatically included in subsequent API calls made by the SDK. This feature is optional and backward compatible; existing initializations withoutacceptLanguage
will continue to function as before. An example has been added toEXAMPLES.md
.Testing
src/networking/__tests__/index.spec.js
to verify theClient
class behavior:Accept-Language
header is not added when theacceptLanguage
option is omitted during initialization.Accept-Language
header is added with the correct value for GET, POST, and PATCH requests when theacceptLanguage
option is provided.acceptLanguage
option is correctly stored during client initialization.Checklist