I'm using AWS Amplify to handle my ReactJS app. While it is convenient that AWS Amplify handles all backend functionality, I don't see any way I can write any of my own backend code to hide from the users. In particular, I'd like to hide my 3rd party API Key, and all the logic associated with the API results. Is there a way I can do this with Amplify or should I just try a different Amazon Compute service?
1
-
1where do you want to use your api keys from? If you think about using them directly from React (i.e. making requests directly from React to a 3rd party API), there is no way of hiding them from the enduser, as they will end up in the pages source code. You need to call the third party app via a function docs.amplify.aws/cli/function. Additionally you can think about storing those secrets in SSM Paramteer Store or AWS Secrets ManagerKorgen– Korgen2021-12-18 11:52:30 +00:00Commented Dec 18, 2021 at 11:52
Add a comment
|
1 Answer
I am new to AWS but if you are asking how to hide the API key you can use the .env file. Create a ".env" file on the root directory and then name it " REACT_APP_apiKey= your API key here". After this point, you can use it anywhere in your react application as in " const myAPI = process.env.REACT_APP_apiKey; "