Gitignore denies access to api-key

hello, i have an app which works just fine, but something goes wrong after uploading it to github.
it is written in javascript and takes an Api-key which is imported from another js-file.
like :
let api-key=“1234”
export {api-key}
i have put the imported js-file in a .gitignore file, and it really ignores that js-file but the problem is, after uploading it to git, the app stops working.
My question is: does the gitignore file prevent the js-file inside to be executed? And does anyone know how to get around this?