diff --git a/src/components/api.ts b/src/components/api.ts index ac09a49..38c5896 100644 --- a/src/components/api.ts +++ b/src/components/api.ts @@ -1,7 +1,18 @@ import { GroupPreview } from './GroupJoinerLink'; import { IInvitation, IEventSignup, ICarpool, IEvent, IGroup } from './types'; -const base = process.env.REACT_APP_API_DOMAIN + 'api'; +const base = (() => { + const domain = + process.env.NODE_ENV === 'production' + ? process.env.REACT_APP_API_PROD + : process.env.REACT_APP_API_LOCAL; + + if (domain?.endsWith('/')) { + return domain.slice(0, -1) + '/api'; + } else { + return domain + '/api'; + } +})(); async function post(path: string, data: any) { const res = await fetch(base + path, {