feat: add configurable auth and API endpoints#275
Merged
Conversation
Add optional authUrl and apiUrl configuration options to CommercetoolsBaseConfig to allow custom endpoint URLs. This enables pointing to mock servers for integration testing while maintaining full backward compatibility. Changes: - Add authUrl and apiUrl optional properties to CommercetoolsBaseConfig - Update CommercetoolsAuthApi to use custom endpoints when provided - Update CommercetoolsApi to use custom endpoints when provided - Both classes fall back to region-based URLs when custom URLs not specified - Add comprehensive test coverage for custom endpoint functionality - Add integration tests verifying requests use custom endpoints correctly All existing tests pass, confirming full backward compatibility. No breaking changes - custom endpoints are optional and default behavior is preserved when not specified.
jimmythomson
approved these changes
Jan 8, 2026
There was a problem hiding this comment.
Pull request overview
This pull request adds support for configurable authentication and API endpoints to enable integration testing with mock servers. The changes introduce optional authUrl and apiUrl configuration properties that override the default region-based endpoint URLs when provided.
Key changes:
- Added optional
authUrlandapiUrlproperties toCommercetoolsBaseConfiginterface with clear documentation - Updated
CommercetoolsAuthApiandCommercetoolsApiclasses to use custom endpoints when provided, falling back to region-based URLs otherwise - Added comprehensive test coverage validating both endpoint configuration and actual request behavior with custom endpoints
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/types.ts | Added optional authUrl and apiUrl properties to CommercetoolsBaseConfig with JSDoc documentation and examples |
| src/lib/auth/CommercetoolsAuthApi.ts | Updated constructor to use custom endpoints when provided via config, with fallback to region-based URLs |
| src/lib/api/CommercetoolsApi.ts | Updated constructor to use custom endpoints when provided via config, with fallback to region-based URLs |
| src/test/auth/CommercetoolsAuthApi.test.ts | Added constructor tests and integration test verifying custom auth endpoint usage in actual requests |
| src/test/auth/CommercetoolsAuth.test.ts | Added configuration tests verifying custom endpoints are properly passed through and integration test with custom endpoint |
| src/test/api/CommercetoolsApi.test.ts | Added constructor tests covering all endpoint configuration combinations and integration test verifying custom endpoints in requests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎉 This PR is included in version 6.16.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Add optional authUrl and apiUrl configuration options to CommercetoolsBaseConfig
to allow custom endpoint URLs. This enables pointing to mock servers for
integration testing while maintaining full backward compatibility.
Changes:
All existing tests pass, confirming full backward compatibility.
No breaking changes - custom endpoints are optional and default behavior
is preserved when not specified.