How to hide a key in react js app (for frontend React and backend salesforce )

51 Views Asked by At

I am using a react app for frontend and salesforce for backend. I want to hide an API key from the users.

I got some solution like .env variables but if I commit the changes then how code will work as the key is in my machine only. I want a method to hide in such a way that user do not have to do something extra just download the package. Is there any method in salesforce or react hide an API key?

2

There are 2 best solutions below

1
Vlad On

In Salesforce, use Named Credentials to securely store API keys and other sensitive information. Named Credentials in Salesforce provide a secure and centralized way to store authentication information.

0
Sirjan Baral On

You can simply put the env file on server or deployment environment and put the file in gitignore and use it locally on prod server it will pick from deployment environment