https://www.growthbook.io/ logo
n

numerous-army-92497

02/20/2023, 2:39 PM
Hi, also an API question, we have deployed gb in AWS ECS and want to use CloudFront to cache the API, our setup is:
APP_ORIGIN: <http://growthbook.ourdomain.com|growthbook.ourdomain.com>
API_HOST: <http://growthbook.ourdomain.com:3100|growthbook.ourdomain.com:3100>
and then we have the CloudFront distribution created as
<http://growthbook-api.ourdomain.com|growthbook-api.ourdomain.com>
The issue now is that we cannot enter
<http://growthbook-api.ourdomain.com|growthbook-api.ourdomain.com>
into the API_HOST environment variable. I'm guessing that is because of the port mapping from container port to host port (or loadbalancer target to container even). As we also can't use any other port than 443 for CloudFront, we're currently not sure how to solve this. Do you have a working example for the GrowthBook API behind CloudFront?
f

future-teacher-7046

02/20/2023, 2:47 PM
API_HOST should contain the publicly accessible host not the internal ecs host, so https://growthbook-api.ourdomain.com in your example
n

numerous-army-92497

02/20/2023, 2:56 PM
We tried that, but then we get the error message
OAuth Error: Error Signing In
when accessing the UI. Only by providing
<http://growthbook.ourdomain.com:3100|growthbook.ourdomain.com:3100>
as API_HOST the setup works. We use Azure AD for SSO.
f

future-teacher-7046

02/20/2023, 2:58 PM
If you go to the CloudFront domain directly do you see a JSON object returned with status info about the API?
n

numerous-army-92497

02/20/2023, 2:59 PM
Yep, that works fine. The only 'issue' is that we cannot set the CloudFront url in the GB environment variables.
f

future-teacher-7046

02/20/2023, 3:00 PM
When you get the OAuth error, are there any other errors in the dev tools console? Like maybe CloudFront is not forwarding cors headers properly
n

numerous-army-92497

02/20/2023, 3:00 PM
So our users see the :3100 url when they look at the feature integration examples or the SDK example in the UI.
f

future-teacher-7046

02/20/2023, 3:02 PM
Oh, I think I was misunderstanding. So everything is working fine and the only thing you want to change is the domain shown in the code examples, is that right?
n

numerous-army-92497

02/20/2023, 3:07 PM
Correct.
f

future-teacher-7046

02/20/2023, 3:09 PM
Ok. We don't have an environment variable to override that yet, but it's easy to add. We do the same on GrowthBook Cloud to show cdn.growthbook.io in instructions. I'll create a github issue
❤️ 1
n

numerous-army-92497

02/20/2023, 3:21 PM
Awesome! Thank you :)
10 Views