I have a node.js/GraphQL server that I created and deployed to elastic beanstalk. On the client, I have a react app with Apollo. The problem is, I am hard coding the URL from the elastic beanstalk app into apollo client. What is the protocol for securing this URL so that no one else can see it? Should I even be concerned about that? I've looked at other services such as Amplify and AppSync. Also, I've seen people using API Gateway. I'm not really sure what I should be looking at to get the right answer. I should clarify that the client will not be hosted on AWS just the node.js server.
1 Answers
1
votes
You could do one of the following:
1) Place the IP address in a file outside of version control (.gitignore) and import that into your app.
2) You could use environment variables.
You can define the variables in your app like the following...
const SomeRandomVariable = process.env.GRAPHQL_IP;
Now, when you go to build your app, you can do the following:
REACT_APP_MY_VAR=10.20.123.456 npm start
Note: If you are on React Native, use react-native-config.
I hope that helps!