https://www.growthbook.io/ logo
#announcements
Title
# announcements
t

thousands-doctor-54767

02/17/2023, 8:41 PM
Hi, is it possible to configure the frontend to call API endpoints behind
/api
instead of on a separate port or subdomain? Tried out:
Copy code
APP_ORIGIN=<http://some.url.com>
API_HOST=<http://some.url.com/api/>
But the frontend seems to handle it inconsistently
f

fresh-football-47124

02/17/2023, 8:43 PM
Not that easily - I did help someone do it with a proxy server to do the redirecting for that use case
t

thousands-doctor-54767

02/17/2023, 8:46 PM
ah, so the the frontend still called the proxy server using a different port or subdomain?
f

fresh-football-47124

02/17/2023, 8:47 PM
ya, we used nginx for rewriting the requests
t

thousands-doctor-54767

02/17/2023, 8:49 PM
got it, I have a proxy set up to rewrite
/api
to the correct api port, but I'm just having trouble getting the frontend to actually call "/api" consistently. for example,
/init
call went to
/api/init
, but
/organization
and
/auth/refresh
did not
f

fresh-football-47124

02/17/2023, 8:50 PM
ya… ah
Copy code
fetch(getApiHost() + "/auth/refresh", {
that should append the right host
t

thousands-doctor-54767

02/17/2023, 8:59 PM
huh, yeah..
oh, ok I see. so
/api/init
is the thing that actually returns the api host env, but I wonder it's getting redirected to the api port because of my proxy
😄 so I should use any other redirect than "/api"
basing that off this:
f

fresh-football-47124

02/17/2023, 9:11 PM
ya
so thinking about it it, not sure this will work
t

thousands-doctor-54767

02/17/2023, 9:11 PM
going to try switching to
Copy code
API_HOST=<http://some.url.com/_api/>
f

fresh-football-47124

02/17/2023, 9:11 PM
since we overload the /api path if this hosts are the same
right
that could do it
since that api/init request is supposed to go to the front end container
👍 1
t

thousands-doctor-54767

02/17/2023, 9:12 PM
thanks @fresh-football-47124
17 Views