:wave: Hello, team! I am getting started with self...
# ask-questions
n
👋 Hello, team! I am getting started with self hosted growthbook deployment and trying to deploy it on a EC2 instance. but facing the issue where it can not connect o API's. I did updated the environment variables as per the docs. can you please help to figure out what's wrong?
f
Hi Dheeraj
Are you getting any errors in the console?
And can you test going to that API url directly?
n
going to api url directly gives cors origin issue as it is not expecting my personal ip as origin
console and network errors
f
that is not a request directly to the API
can you open the port 3100 url directly?
if its working it should give you a json object back
n
it will give me cors origin access issue
I found the issue.
by looking into logs of docker compose
f
cool, what was it?
n
you should probably update the docs to change
ENV
to non prod and
JWT_SECRET
is mandatory for PROD
It was asking to provide a random key for
JWT_SECRET
f
ya, if you don’t change it, we throw an error
1
n
it wasn't mention anywhere in get started doc
f
ya, I’ll make it clearer
🙏 1
n
thankyou so much
f
Updated the self configuration documentation. Added this:
When using GrowthBook in production, it is important to change the
NODE_ENV
to to “production” and change the
JWT_SECRET
to a random string. Using the
production
node environment and the default
JWT_SECRET
will throw an error.
🙏 1
n
great. thanks @fresh-football-47124
Just wondering if I provide
APP_ORIGIN
and
API_HOST
it by default assume that's its a prod environment right?
f
We thought about that, but there are cases where that is not true
😟 1
e
I am getting this issue now. Adding NODE_ENV and JWT_SECRET didnt seem to help
message has been deleted
message has been deleted
message has been deleted
Anyone have any ideas. It was working until I added NODE_ENV and JWT_SECRET.
f
Can you go to the url of the API directly? If it's working, you should get a json object
e
I get a 502 error
f
That seems like the problem- if your running in docker, are their any errors in the console there?
e
I have an error in the logs about using JWT_secret=dev being not allowed.
But, I have set that in my docker-compose.yml file.
f
Sounds like it hasn't pulled in those changes
e
is
docker-compose restart growthbook
an appropriate way to get those updated?
f
@future-teacher-7046 do you know?
e
Looks like
Copy code
ENCRYPTION_KEY=<long-string>
Is required as well.
Alright, that should probably be somewhere in the docs. Its working again.
f
@proud-baker-47556 is that new?
Great! Glad you got it sorted
e
Still have the issue of multiple
Access-Control-Allow-Origin
rows.
I was hoping messing around with the ENV variables would resolve, but alas.
f
That's from the front end request?
e
Yes: Calling it from insomnia
<https://growthbook-api.fm.co/api/features/><key>
Also from react:
Copy code
useEffect(() => {
    // Load feature definitions from GrowthBook API
    fetch("<https://growthbook-api.fm.co/api/features/><key>")
message has been deleted
f
The API only sends a single access control header. Do you have nginx or another reverse proxy in front? It's possible that is adding a second one
🙌 1