Skip to content

Commit

Permalink
fix:(webAuthn) use globalThis, not process.env (#7639)
Browse files Browse the repository at this point in the history
* fix: use globalThis, not process.env

* copy how dbAuth does it
  • Loading branch information
jtoar authored Feb 14, 2023
1 parent 04c49ad commit 89f851d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WebAuthnClient from '../webAuthn'

process.env.RWJS_API_URL = '/.redwood/functions'
globalThis.RWJS_API_URL = '/.redwood/functions'

jest.mock('@whatwg-node/fetch', () => {
return
Expand Down Expand Up @@ -81,12 +81,12 @@ describe('webAuthn', () => {

expect(mockOpen).toBeCalledWith(
'GET',
`${process.env.RWJS_API_URL}/auth?method=webAuthnAuthOptions`,
`${globalThis.RWJS_API_URL}/auth?method=webAuthnAuthOptions`,
false
)
expect(mockOpen).toBeCalledWith(
'POST',
`${process.env.RWJS_API_URL}/auth`,
`${globalThis.RWJS_API_URL}/auth`,
false
)
expect(mockSend).toBeCalledWith(
Expand Down Expand Up @@ -122,12 +122,12 @@ describe('webAuthn', () => {

expect(mockOpen).toBeCalledWith(
'GET',
`${process.env.RWJS_API_URL}/auth?method=webAuthnRegOptions`,
`${globalThis.RWJS_API_URL}/auth?method=webAuthnRegOptions`,
false
)
expect(mockOpen).toBeCalledWith(
'POST',
`${process.env.RWJS_API_URL}/auth`,
`${globalThis.RWJS_API_URL}/auth`,
false
)
expect(mockSend).toBeCalledWith(
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/web/src/webAuthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class WebAuthnClient {
authApiUrl = ''

private getAuthApiUrl() {
return this.authApiUrl || `${process.env.RWJS_API_URL}/auth`
return this.authApiUrl || `${RWJS_API_URL}/auth`
}

setAuthApiUrl(authApiUrl?: string) {
Expand Down

0 comments on commit 89f851d

Please sign in to comment.