Use generalized prod config var (#3574)

This commit is contained in:
Christian Byrne
2025-04-23 10:26:31 +08:00
committed by GitHub
parent 612500a4dc
commit 3bd508c001
7 changed files with 27 additions and 25 deletions

View File

@@ -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

2
global.d.ts vendored
View File

@@ -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 {
/**

3
src/config/comfyApi.ts Normal file
View File

@@ -0,0 +1,3 @@
export const COMFY_API_BASE_URL = __USE_PROD_CONFIG__
? 'https://api.comfy.org'
: 'https://stagingapi.comfy.org'

View File

@@ -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

View File

@@ -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<CreateCustomerResponse> => {
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',

View File

@@ -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: {

View File

@@ -16,5 +16,8 @@ export default defineConfig({
alias: {
'@': '/src'
}
},
define: {
__USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true'
}
})