chore: moving VITE_KC_API_BASE_URL to the helper function
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
import {
|
||||
withAPIBaseURL
|
||||
} from '@src/lib/withBaseURL'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
describe('withBaseURL', () => {
|
||||
/**
|
||||
@ -18,7 +16,7 @@ describe('withBaseURL', () => {
|
||||
const actual = withAPIBaseURL('/users')
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
it ('should return a longer base url with /oauth2/token/revoke', () => {
|
||||
it('should return a longer base url with /oauth2/token/revoke', () => {
|
||||
const expected = 'https://api.dev.zoo.dev/oauth2/token/revoke'
|
||||
const actual = withAPIBaseURL('/oauth2/token/revoke')
|
||||
expect(actual).toBe(expected)
|
||||
@ -27,8 +25,8 @@ describe('withBaseURL', () => {
|
||||
const expected = 'https://api.dev.zoo.dev'
|
||||
const actual = withAPIBaseURL('')
|
||||
expect(actual).toBe(expected)
|
||||
const expectedEndsWith = expected[expected.length-1]
|
||||
const actualEndsWith = actual[actual.length-1]
|
||||
const expectedEndsWith = expected[expected.length - 1]
|
||||
const actualEndsWith = actual[actual.length - 1]
|
||||
expect(actual).toBe(expected)
|
||||
expect(actualEndsWith).toBe(expectedEndsWith)
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { VITE_KC_API_BASE_URL } from '@src/env'
|
||||
|
||||
export function withAPIBaseURL (path: string) : string {
|
||||
export function withAPIBaseURL(path: string): string {
|
||||
return VITE_KC_API_BASE_URL + path
|
||||
}
|
||||
|
@ -10,9 +10,7 @@ import {
|
||||
} from '@src/lib/desktop'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { markOnce } from '@src/lib/performance'
|
||||
import {
|
||||
withAPIBaseURL
|
||||
} from '@src/lib/withBaseURL'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
import { ACTOR_IDS } from '@src/machines/machineConstants'
|
||||
|
||||
export interface UserContext {
|
||||
|
@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
|
||||
import { ActionButton } from '@src/components/ActionButton'
|
||||
import { CustomIcon } from '@src/components/CustomIcon'
|
||||
import { Logo } from '@src/components/Logo'
|
||||
import { VITE_KC_API_BASE_URL, VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { VITE_KC_SITE_BASE_URL } from '@src/env'
|
||||
import { APP_NAME } from '@src/lib/constants'
|
||||
import { isDesktop } from '@src/lib/isDesktop'
|
||||
import { openExternalBrowserIfDesktop } from '@src/lib/openWindow'
|
||||
@ -15,6 +15,7 @@ import { reportRejection } from '@src/lib/trap'
|
||||
import { toSync } from '@src/lib/utils'
|
||||
import { authActor, useSettings } from '@src/lib/singletons'
|
||||
import { APP_VERSION, generateSignInUrl } from '@src/routes/utils'
|
||||
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
||||
|
||||
const subtleBorder =
|
||||
'border border-solid border-chalkboard-30 dark:border-chalkboard-80'
|
||||
@ -54,7 +55,7 @@ const SignIn = () => {
|
||||
const signInDesktop = async () => {
|
||||
// We want to invoke our command to login via device auth.
|
||||
const userCodeToDisplay = await window.electron
|
||||
.startDeviceFlow(VITE_KC_API_BASE_URL + location.search)
|
||||
.startDeviceFlow(withAPIBaseURL(location.search))
|
||||
.catch(reportError)
|
||||
if (!userCodeToDisplay) {
|
||||
console.error('No user code received while trying to log in')
|
||||
|
Reference in New Issue
Block a user