Is it possible to host Growthbook and Growthbook’s...
# announcements
b
Is it possible to host Growthbook and Growthbook’s API in a single domain? The documentation for APP_ORIGIN and API_HOST specifies them to be different, but I wonder if I can host them in one domain but using a separate prefix instead (e.g. my-growthbook.com and my-growthbook.com/api)
f
There are a few options. You can use the same domain with different ports. Or you can use different subdomains. It might be possible to route traffic to different subdirectories using a reverse proxy like nginx, although you might run into issues.
b
Thanks for the response. Let me try the nginx option and see if there are issues. Unfortunately where I work at right now setting up multiple domain/subdomain (especially with custom ports) is very inconvenient as compared to tinkering with the infrastructure.
Thought I’d post an update here in case this is of interest. For context, all of this is inside a Kubernetes (GKE), so nginx refers to an nginx ingress controller. 1. In the beginning I put an nginx which simply maps the Growthbook’s app doman (e.g. my-gb.com) to service’s port 3000, and Growthbook’s API origin (e.g. my-gb.com/custom-api) into the service’s port 3100. ◦ This does not work. The landing page loads, but calls to the custom-api/auth/refresh fails with authorisation token not found. ◦ I have no knowledge of how next.js works, but I suspect any call to <app-domain>/<path> needs to be authenticated, except the auth/refresh 2. Knowing the problem in 1, my next attempt is to get nginx to rewrite the URLs. So if the browser sends (my-gb.com/custom-api), I need to get nginx to map it to the service’s port 3100, and remove the
custom-api
prefix. This can be done with nginx’s _rewrite-target_ annotation. Due to the complexity of the regex, I try to keep things simple by splitting the application and the api to be handled by two separate nginx ingress controllers. a. This seem to work, at least I’ve tried browsing around and there’s no error in the browser’s console so far b. It continues to work after I remove all the allow CORS headers from my ingress controller c. Having said that I’m not sure if this would work for all cases, since now I’m at the mercy of the regex replacement.
329 Views