From 2fbbc660297d8ed39c66e8dc53c1f687b72f6748 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Wed, 29 Jun 2022 16:31:53 -0700 Subject: [PATCH] Point v2 functions @ localhost during emulation (#597) --- web/lib/firebase/api-call.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/lib/firebase/api-call.ts b/web/lib/firebase/api-call.ts index d46b3afa..7509a9f1 100644 --- a/web/lib/firebase/api-call.ts +++ b/web/lib/firebase/api-call.ts @@ -41,8 +41,13 @@ export async function call(url: string, method: string, params: any) { // one less hop export function getFunctionUrl(name: string) { - const { cloudRunId, cloudRunRegion } = ENV_CONFIG - return `https://${name}-${cloudRunId}-${cloudRunRegion}.a.run.app` + if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) { + const { projectId, region } = ENV_CONFIG.firebaseConfig + return `http://localhost:5001/${projectId}/${region}/${name}` + } else { + const { cloudRunId, cloudRunRegion } = ENV_CONFIG + return `https://${name}-${cloudRunId}-${cloudRunRegion}.a.run.app` + } } export function createMarket(params: any) {