What is the best way to securely store my API keys on Heroku while ensuring my app can still access them?

I have recently completed developing a Node application and I am now in the process of deploying it on Heroku. Within my app, I utilize various API keys which are stored in a separate file that is accessed using exports throughout the application. The APIkey file has been added to the .gitignore file to ensure its security. However, upon deploying my application to Heroku, I encountered some issues.

When attempting to access my app, here is an excerpt from the log:

2018-12-19T23:38:14.937951+00:00 heroku[web.1]: Starting process with command npm start

... (remaining log details)

This being my first real application, I acknowledge my limited experience in this area. It is evident that my current approach may not be correct. The primary query pertains to the handling of APIkeys - if they are not supposed to be included and hidden in the .gitignore file, what alternative method should be employed to safeguard these keys while still allowing Heroku to effectively run the application?

Locally, my application runs smoothly by executing npm start with the app.js file. Please let me know if you require additional information.

Answer №1

Just wanted to give an update that I have found the solution to my query. It turns out, I had been mistaken about the functionality of .gitignore. Instead, I opted for a basic environment file and everything is now running smoothly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS-WHAT Package for Angular Update - Enhance Your Styles!

In my Angular setup, the configurations are as follows: _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | ...

What steps should I take to rectify the errors encountered during the initialization of a fresh Angular project?

Can someone assist me with my updated question? https://i.stack.imgur.com/f8an5.png Click here for the image description. ...

Using ES6 import with the 'request' npm module: A Step-by-Step Guide

When updating TypeScript code to ES6 (which runs in the browser and Node server, with a goal of tree-shaking the browser bundle), I am attempting to replace all instances of require with import. However, I encountered an issue... import * as request from ...

Console displays 'undefined' when using the post method with Node.js/Express

Below is the code for my upload.ejs page: <%- include('header' ,{ title:"Playground" }) -%> <div class="wrapper"> <form action="/upload" method="POST" enctype="multipart/form-data"> <input type="text" name="name" place ...

What is the best method to transform URI data encoded in base64 into a file on the server side?

Looking for a solution to save a URI-data string as a jpg on the server using only Javascript. The alternative of writing it to a canvas and reading the image from there is not ideal. Any ideas? ...

Simple script for Windows to ensure continuous operation of node

Currently, I have a very basic script in a .bat file to ensure that my node.js server stays running on a Windows machine. : loop npm start goto loop : end Nevertheless, if the server crashes, it fails to restart automatically. While I am aware of more e ...

Troubles When Setting Up Gulp

Having some trouble getting Gulp to function properly on my Ubuntu system. After running the command to install Gulp, there are no reported errors. However, when I try to run gulp -v post-installation, it doesn't seem to work as expected. npm version ...

Is there a way for me to store the retrieved information from an API into a global variable using Node.js?

function request2API(option){ const XMLHttpRequest = require('xhr2');//Cargar módulo para solicitudes xhr2 const request = new XMLHttpRequest(); request.open('GET', urlStart + ChList[option].videosList + keyPrefix + key); request. ...

The specified public directory could not be located

I'm trying to utilize Node.js with Express, and I recently found out about being able to specify a 'public' directory for serving static files. I've been attempting to place my bootstrap css/js files in the public directory, but I keep ...

FirebaseCloudMessaging : PlatformException (PlatformException(null-error, The host platform unexpectedly returned a null value for a non-null return value., null, null))

I am currently facing a challenge in sending notifications from a Node.js API to a Flutter application. Initially, my goal is to enable my application to receive notifications from Firebase. However, I encountered an issue when initializing the app: Pla ...

Manipulate JSON data in a Node.js loop

Currently, I am working on a monitoring system that will indicate on a website whether a server is up or down. I have experimented with various methods such as regex and replacement to modify the JSON file. My main objective is to dynamically change the "s ...

Looking for another alternative to discord.js EvaluatedPermissions?

Before when I was using v11.x.x, my dashboard.js had a section that looked like this: const perms = Discord.EvaluatedPermissions; renderTemplate(res, req, "dashboard.ejs", {perms}); However, after updating the bot to discord.js v12, 'perms&a ...

What is the best way to store a WAV Blob in MongoDB, fetch it accurately, and serve it using Node

While there are many resources available on saving binary files using the Mongoose Buffer SchemaType, most of them focus on image files. I have encountered difficulties in making it work with a WAV audio file. Currently, I am utilizing Recorder.js to stor ...

I am encountering some difficulties in the installation process of Angular CLI

Encountering an error trying to install angular cli despite updating both node and npm. https://i.stack.imgur.com/SpkNU.jpg ...

Why are imported modules unable to reach global variables in Node?

As I delve deeper into using ES6 and organizing my code across multiple files for better readability and version control, I've encountered an issue that has me puzzled. In one of my scenarios, I have a class defined in a separate file called class.js, ...

Tips for avoiding EADDRINUSE error when conducting database tests with Jest, Graphql, and Sequelize

Trying to test a mock database using Jest and Sequelize, I have created a helper function that runs before each test suite: export function handleTestDatabase() { beforeAll(() => { testDatabase.sequelize.sync().then(() => app.listen(0)); }); ...

Avoid the import of @types definition without exports in TypeScript to prevent the error TS2306 (not a module)

I have spent a considerable amount of time trying to load a NodeJS library that has what I believe is a faulty type definition in the @types repository. The library in question is geolib and its types can be found in @types/geolib Although I am aware tha ...

What sets apart yarn/npm5 lockfiles from precise package versions?

I'm curious why I can't specify exact versions in my package.json. How does this differ from using a lockfile? ...

Save the result of a terminal command into an sqlite database

When I run a particular shell command in node js, the output is displayed on the console. Is there a method to store this output in a variable so that it can be POSTed to an Sqlite database? const shell = require('shelljs'); shell.exec('a ...

What is the process for deploying a Next.js application from a monorepo created with Turborepo to Azure Web Apps?

I manage a monorepo containing multiple nextjs apps built with Turborepo, and I want to deploy them to Azure Web App. Each app should be able to deploy independently on Azure Web App, but I also want to explore hosting them on a single Azure Web Apps insta ...