mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-16 00:50:18 -04:00
make api domain more flexible
This commit is contained in:
parent
3a761ffc8b
commit
d276d02cc4
|
@ -1,7 +1,18 @@
|
||||||
import { GroupPreview } from './GroupJoinerLink';
|
import { GroupPreview } from './GroupJoinerLink';
|
||||||
import { IInvitation, IEventSignup, ICarpool, IEvent, IGroup } from './types';
|
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) {
|
async function post(path: string, data: any) {
|
||||||
const res = await fetch(base + path, {
|
const res = await fetch(base + path, {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user