Repository navigation
Conversation
…KOS_API_HTTPS Falls back to the same environment variables @workos-inc/authkit-nextjs reads when the apiHostname, port and https options are not passed, so an app can be pointed at @workos/emulate or a mock server without code changes. Constructor options still take precedence. Closes workos#1766
Contributor
[Medium impact] The PR appears safe to merge; the previous test-isolation issue is fixed. SummaryThe PR lets
Reviews (2) · Last reviewed commit: "test: Clear API host environment variabl..." · Reviewed by Greptile |
Author
|
@awolfden Is this ready to go? This would be helpful to get in so that CI against a simulator doesn't need a code change. |
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.
Description
Closes #1766.
When the
apiHostname,portandhttpsoptions are not passed, the constructor now falls back toWORKOS_API_HOSTNAME,WORKOS_API_PORTandWORKOS_API_HTTPS, the same variables@workos-inc/authkit-nextjsreads, parsed the same way:WORKOS_API_HTTPS:httpsonly when the value is"true"; unset keeps thehttpsdefault.WORKOS_API_PORT:parseInt; unset means no port.Constructor options still take precedence, and with none of the variables set the base URL is unchanged (
https://api.workos.com). This lets an existing app, e.g. one that callsnew WorkOS(process.env.WORKOS_API_KEY, { clientId }), run against@workos/emulateor a mock server by configuration alone.Changes:
src/workos.ts: environment fallback for the three options.src/workos.spec.ts: tests for the variables, precedence of constructor options, and the unset default.README.md: a short note under Configuration.npm run prettier,typecheck,linton the changed files,test(1418 passed) andbuildall pass.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.