diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 434586c2f..660cc061a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: SENTRY_DSN: ${{ secrets.SENTRY_DSN }} ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }} - USE_PROD_FIREBASE_CONFIG: 'true' + USE_PROD_CONFIG: 'true' run: | npm ci npm run build diff --git a/global.d.ts b/global.d.ts index f7be326a4..73019099a 100644 --- a/global.d.ts +++ b/global.d.ts @@ -3,7 +3,7 @@ declare const __SENTRY_ENABLED__: boolean declare const __SENTRY_DSN__: string declare const __ALGOLIA_APP_ID__: string declare const __ALGOLIA_API_KEY__: string -declare const __USE_PROD_FIREBASE_CONFIG__: boolean +declare const __USE_PROD_CONFIG__: boolean interface Navigator { /** diff --git a/src/config/comfyApi.ts b/src/config/comfyApi.ts new file mode 100644 index 000000000..386323fdb --- /dev/null +++ b/src/config/comfyApi.ts @@ -0,0 +1,3 @@ +export const COMFY_API_BASE_URL = __USE_PROD_CONFIG__ + ? 'https://api.comfy.org' + : 'https://stagingapi.comfy.org' diff --git a/src/config/firebase.ts b/src/config/firebase.ts index a8a62c1cd..c3dc718a1 100644 --- a/src/config/firebase.ts +++ b/src/config/firebase.ts @@ -1,15 +1,15 @@ import { FirebaseOptions } from 'firebase/app' -// const DEV_CONFIG: FirebaseOptions = { -// apiKey: 'AIzaSyDa_YMeyzV0SkVe92vBZ1tVikWBmOU5KVE', -// authDomain: 'dreamboothy-dev.firebaseapp.com', -// databaseURL: 'https://dreamboothy-dev-default-rtdb.firebaseio.com', -// projectId: 'dreamboothy-dev', -// storageBucket: 'dreamboothy-dev.appspot.com', -// messagingSenderId: '313257147182', -// appId: '1:313257147182:web:be38f6ebf74345fc7618bf', -// measurementId: 'G-YEVSMYXSPY' -// } +const DEV_CONFIG: FirebaseOptions = { + apiKey: 'AIzaSyDa_YMeyzV0SkVe92vBZ1tVikWBmOU5KVE', + authDomain: 'dreamboothy-dev.firebaseapp.com', + databaseURL: 'https://dreamboothy-dev-default-rtdb.firebaseio.com', + projectId: 'dreamboothy-dev', + storageBucket: 'dreamboothy-dev.appspot.com', + messagingSenderId: '313257147182', + appId: '1:313257147182:web:be38f6ebf74345fc7618bf', + measurementId: 'G-YEVSMYXSPY' +} const PROD_CONFIG: FirebaseOptions = { apiKey: 'AIzaSyC2-fomLqgCjb7ELwta1I9cEarPK8ziTGs', @@ -22,8 +22,7 @@ const PROD_CONFIG: FirebaseOptions = { measurementId: 'G-3ZBD3MBTG4' } -// To test with prod config while using dev server, set USE_PROD_FIREBASE_CONFIG=true in .env -// Otherwise, build with `npm run build` the and set `--front-end-root` to `ComfyUI_frontend/dist` -export const FIREBASE_CONFIG: FirebaseOptions = __USE_PROD_FIREBASE_CONFIG__ +// To test with prod config while using dev server, set USE_PROD_CONFIG=true in .env +export const FIREBASE_CONFIG: FirebaseOptions = __USE_PROD_CONFIG__ ? PROD_CONFIG - : PROD_CONFIG // Just force prod to save time for now. change back later + : DEV_CONFIG diff --git a/src/stores/firebaseAuthStore.ts b/src/stores/firebaseAuthStore.ts index 83569e3a1..863497f1c 100644 --- a/src/stores/firebaseAuthStore.ts +++ b/src/stores/firebaseAuthStore.ts @@ -16,6 +16,7 @@ import { defineStore } from 'pinia' import { computed, ref } from 'vue' import { useFirebaseAuth } from 'vuefire' +import { COMFY_API_BASE_URL } from '@/config/comfyApi' import { t } from '@/i18n' import { useDialogService } from '@/services/dialogService' import { operations } from '@/types/comfyRegistryTypes' @@ -35,9 +36,6 @@ type AccessBillingPortalResponse = type AccessBillingPortalReqBody = operations['AccessBillingPortal']['requestBody'] -// TODO: Switch to prod api based on environment (requires prod api to be ready) -const API_BASE_URL = 'https://stagingapi.comfy.org' - export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { // State const loading = ref(false) @@ -105,7 +103,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { return null } - const response = await fetch(`${API_BASE_URL}/customers/balance`, { + const response = await fetch(`${COMFY_API_BASE_URL}/customers/balance`, { headers: { Authorization: `Bearer ${token}` } @@ -137,7 +135,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { const createCustomer = async ( token: string ): Promise => { - const createCustomerRes = await fetch(`${API_BASE_URL}/customers`, { + const createCustomerRes = await fetch(`${COMFY_API_BASE_URL}/customers`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -243,7 +241,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { customerCreated.value = true } - const response = await fetch(`${API_BASE_URL}/customers/credit`, { + const response = await fetch(`${COMFY_API_BASE_URL}/customers/credit`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -284,7 +282,7 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { return null } - const response = await fetch(`${API_BASE_URL}/customers/billing`, { + const response = await fetch(`${COMFY_API_BASE_URL}/customers/billing`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/vite.config.mts b/vite.config.mts index 56e5182d6..1949c0a20 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -115,8 +115,7 @@ export default defineConfig({ __SENTRY_DSN__: JSON.stringify(process.env.SENTRY_DSN || ''), __ALGOLIA_APP_ID__: JSON.stringify(process.env.ALGOLIA_APP_ID || ''), __ALGOLIA_API_KEY__: JSON.stringify(process.env.ALGOLIA_API_KEY || ''), - __USE_PROD_FIREBASE_CONFIG__: - process.env.USE_PROD_FIREBASE_CONFIG === 'true' + __USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true' }, resolve: { diff --git a/vitest.config.ts b/vitest.config.ts index c923263d6..d07dda0ad 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -16,5 +16,8 @@ export default defineConfig({ alias: { '@': '/src' } + }, + define: { + __USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true' } })