I was wondering if there is a way to hide API codes in JavaScript files.
I would like to use some projects to show off on my portfolio website. However, some are with API codes. To this day i haven’t really found a way to hide my API codes (such as accu weather, spotify…).
The most common way is to use an environment variable, you create a special .ENV file to store keys (which you keep locally and do not share/push) and then use a module like dotenv to process them:
Also depending on how you are hosting the project, most hosting providers (i.e Heroku) have the ability to add and securely access keys and the like but that will vary depending on where the project is running.