Skip to content

Commit 3bd508c

Browse files
Use generalized prod config var (#3574)
1 parent 612500a commit 3bd508c

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
3030
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
3131
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
32-
USE_PROD_FIREBASE_CONFIG: 'true'
32+
USE_PROD_CONFIG: 'true'
3333
run: |
3434
npm ci
3535
npm run build

global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ declare const __SENTRY_ENABLED__: boolean
33
declare const __SENTRY_DSN__: string
44
declare const __ALGOLIA_APP_ID__: string
55
declare const __ALGOLIA_API_KEY__: string
6-
declare const __USE_PROD_FIREBASE_CONFIG__: boolean
6+
declare const __USE_PROD_CONFIG__: boolean
77

88
interface Navigator {
99
/**

src/config/comfyApi.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const COMFY_API_BASE_URL = __USE_PROD_CONFIG__
2+
? 'https://api.comfy.org'
3+
: 'https://stagingapi.comfy.org'

src/config/firebase.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { FirebaseOptions } from 'firebase/app'
22

3-
// const DEV_CONFIG: FirebaseOptions = {
4-
// apiKey: 'AIzaSyDa_YMeyzV0SkVe92vBZ1tVikWBmOU5KVE',
5-
// authDomain: 'dreamboothy-dev.firebaseapp.com',
6-
// databaseURL: 'https://dreamboothy-dev-default-rtdb.firebaseio.com',
7-
// projectId: 'dreamboothy-dev',
8-
// storageBucket: 'dreamboothy-dev.appspot.com',
9-
// messagingSenderId: '313257147182',
10-
// appId: '1:313257147182:web:be38f6ebf74345fc7618bf',
11-
// measurementId: 'G-YEVSMYXSPY'
12-
// }
3+
const DEV_CONFIG: FirebaseOptions = {
4+
apiKey: 'AIzaSyDa_YMeyzV0SkVe92vBZ1tVikWBmOU5KVE',
5+
authDomain: 'dreamboothy-dev.firebaseapp.com',
6+
databaseURL: 'https://dreamboothy-dev-default-rtdb.firebaseio.com',
7+
projectId: 'dreamboothy-dev',
8+
storageBucket: 'dreamboothy-dev.appspot.com',
9+
messagingSenderId: '313257147182',
10+
appId: '1:313257147182:web:be38f6ebf74345fc7618bf',
11+
measurementId: 'G-YEVSMYXSPY'
12+
}
1313

1414
const PROD_CONFIG: FirebaseOptions = {
1515
apiKey: 'AIzaSyC2-fomLqgCjb7ELwta1I9cEarPK8ziTGs',
@@ -22,8 +22,7 @@ const PROD_CONFIG: FirebaseOptions = {
2222
measurementId: 'G-3ZBD3MBTG4'
2323
}
2424

25-
// To test with prod config while using dev server, set USE_PROD_FIREBASE_CONFIG=true in .env
26-
// Otherwise, build with `npm run build` the and set `--front-end-root` to `ComfyUI_frontend/dist`
27-
export const FIREBASE_CONFIG: FirebaseOptions = __USE_PROD_FIREBASE_CONFIG__
25+
// To test with prod config while using dev server, set USE_PROD_CONFIG=true in .env
26+
export const FIREBASE_CONFIG: FirebaseOptions = __USE_PROD_CONFIG__
2827
? PROD_CONFIG
29-
: PROD_CONFIG // Just force prod to save time for now. change back later
28+
: DEV_CONFIG

src/stores/firebaseAuthStore.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { defineStore } from 'pinia'
1616
import { computed, ref } from 'vue'
1717
import { useFirebaseAuth } from 'vuefire'
1818

19+
import { COMFY_API_BASE_URL } from '@/config/comfyApi'
1920
import { t } from '@/i18n'
2021
import { useDialogService } from '@/services/dialogService'
2122
import { operations } from '@/types/comfyRegistryTypes'
@@ -35,9 +36,6 @@ type AccessBillingPortalResponse =
3536
type AccessBillingPortalReqBody =
3637
operations['AccessBillingPortal']['requestBody']
3738

38-
// TODO: Switch to prod api based on environment (requires prod api to be ready)
39-
const API_BASE_URL = 'https://stagingapi.comfy.org'
40-
4139
export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
4240
// State
4341
const loading = ref(false)
@@ -105,7 +103,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
105103
return null
106104
}
107105

108-
const response = await fetch(`${API_BASE_URL}/customers/balance`, {
106+
const response = await fetch(`${COMFY_API_BASE_URL}/customers/balance`, {
109107
headers: {
110108
Authorization: `Bearer ${token}`
111109
}
@@ -137,7 +135,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
137135
const createCustomer = async (
138136
token: string
139137
): Promise<CreateCustomerResponse> => {
140-
const createCustomerRes = await fetch(`${API_BASE_URL}/customers`, {
138+
const createCustomerRes = await fetch(`${COMFY_API_BASE_URL}/customers`, {
141139
method: 'POST',
142140
headers: {
143141
'Content-Type': 'application/json',
@@ -243,7 +241,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
243241
customerCreated.value = true
244242
}
245243

246-
const response = await fetch(`${API_BASE_URL}/customers/credit`, {
244+
const response = await fetch(`${COMFY_API_BASE_URL}/customers/credit`, {
247245
method: 'POST',
248246
headers: {
249247
'Content-Type': 'application/json',
@@ -284,7 +282,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
284282
return null
285283
}
286284

287-
const response = await fetch(`${API_BASE_URL}/customers/billing`, {
285+
const response = await fetch(`${COMFY_API_BASE_URL}/customers/billing`, {
288286
method: 'POST',
289287
headers: {
290288
'Content-Type': 'application/json',

vite.config.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export default defineConfig({
115115
__SENTRY_DSN__: JSON.stringify(process.env.SENTRY_DSN || ''),
116116
__ALGOLIA_APP_ID__: JSON.stringify(process.env.ALGOLIA_APP_ID || ''),
117117
__ALGOLIA_API_KEY__: JSON.stringify(process.env.ALGOLIA_API_KEY || ''),
118-
__USE_PROD_FIREBASE_CONFIG__:
119-
process.env.USE_PROD_FIREBASE_CONFIG === 'true'
118+
__USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true'
120119
},
121120

122121
resolve: {

vitest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ export default defineConfig({
1616
alias: {
1717
'@': '/src'
1818
}
19+
},
20+
define: {
21+
__USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true'
1922
}
2023
})

0 commit comments

Comments
 (0)