How to store Firebase credentials in Vue.js projects after building (env_var)How to manage a redirect request after a jQuery Ajax callHow to Check if element is visible after scrolling?Webpack “Uncaught Type Error” when importing Firebase module into standard Vue.js projectFirebase API Key HidingVue.js + Firebase Hosting + Firebase Functionsyo ember tutorial: Client doesn't have permission to access the desired dataGetting user email from firebase using Vue.jsHow can I apply the Heroku generated server port to my front-end Vue.js app?Is there a GCP / Firebase endpoint that returns or generates a firebase project “Browser API Key”

What makes a smart phone "kosher"?

Bit one of the Intel 8080's Flags register

Usage of blank space in trade banner and text-positioning

What organs or modifications would be needed for a life biological creature not to require sleep?

How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?

Why don't Wizards use wrist straps to protect against disarming charms?

Where is it? - The Google Earth Challenge Ep. 1

How do we know that black holes are spinning?

Why is the Digital 0 not 0V in computer systems?

Output a Super Mario Image

Can a character with good/neutral alignment attune to a sentient object with evil alignment?

Is there any way to land a rover on the Moon without using any thrusters?

How to publish superseding results without creating enemies

What do the French say for “Oh, you shouldn’t have”?

In what sequence should an advanced civilization teach technology to medieval society to maximize rate of adoption?

Are there any “Third Order” acronyms used in space exploration?

Is there any reason to concentrate on the Thunderous Smite spell after using its effects?

Make 2019 with single digits

Permutations in Disguise

What next step can I take in solving this sudoku?

Is a suit against a University Dorm for changing policies on a whim likely to succeed (USA)?

What exactly is a marshrutka (маршрутка)?

Has SHA256 been broken by Treadwell Stanton DuPont?

Reading double values from a text file



How to store Firebase credentials in Vue.js projects after building (env_var)


How to manage a redirect request after a jQuery Ajax callHow to Check if element is visible after scrolling?Webpack “Uncaught Type Error” when importing Firebase module into standard Vue.js projectFirebase API Key HidingVue.js + Firebase Hosting + Firebase Functionsyo ember tutorial: Client doesn't have permission to access the desired dataGetting user email from firebase using Vue.jsHow can I apply the Heroku generated server port to my front-end Vue.js app?Is there a GCP / Firebase endpoint that returns or generates a firebase project “Browser API Key”






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have been trying to deploy my firebase&vue app.
However I couldn't add firebase credentials to the env variable.



Basically this is the structure on vue.js




  • config



    ---- key.js



    ---- keys_dev.js



    ---- keys_prod.js



key.js



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_prod');
else
module.exports = require('./keys_dev');



keys_dev.js



module.exports = 
firebase:
apiKey: "*********************************",
authDomain: "*****************************",
databaseURL: "****************************",
projectId: "******************************",
storageBucket: "**************************",
messagingSenderId: "**********************",




keys_prod.js



module.exports = 
firebase:
apiKey: process.env['FIREBASE_apiKey'],
authDomain: process.env['FIREBASE_authDomain'],
databaseURL: process.env['FIREBASE_databaseURL'],
projectId: process.env['FIREBASE_projectId'],
storageBucket: process.env['FIREBASE_storageBucket'],
messagingSenderId: process.env['FIREBASE_messagingSenderId'],




Also I tried like this in keys_prod.js but I guess we can not use object in the env_var, so I changed it to the code above.



module.exports = 
firebase: process.env.FIREBASE_CONFIG



After npm run build, I created express app, define process.env's however when I run server, I am getting error because of env_vars are missing.
I tried to see logs on both front and backend console. I can see envs on node console but not in browser.
I also tried to deploy this app to heroku and firebase hosting. In both cases I added envs externally, but nothing change. (I guess there is no difference to use env_vars in localhost or remote server right ?)



Finally I tried to change keys.js (keys_prod > keys_dev)



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_dev');
else
module.exports = require('./keys_dev');



then it works, but I can find the credentials in the source code this time.










share|improve this question
























  • Can you try VUE_APP_FIREBASE_CONFIG and confirm

    – Varit J Patel
    Mar 28 at 11:27











  • keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

    – Caner Sezgin
    Mar 28 at 12:04












  • Tell me do you want to put the firebase variable in env file or .js works?

    – Varit J Patel
    Mar 28 at 12:07

















1















I have been trying to deploy my firebase&vue app.
However I couldn't add firebase credentials to the env variable.



Basically this is the structure on vue.js




  • config



    ---- key.js



    ---- keys_dev.js



    ---- keys_prod.js



key.js



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_prod');
else
module.exports = require('./keys_dev');



keys_dev.js



module.exports = 
firebase:
apiKey: "*********************************",
authDomain: "*****************************",
databaseURL: "****************************",
projectId: "******************************",
storageBucket: "**************************",
messagingSenderId: "**********************",




keys_prod.js



module.exports = 
firebase:
apiKey: process.env['FIREBASE_apiKey'],
authDomain: process.env['FIREBASE_authDomain'],
databaseURL: process.env['FIREBASE_databaseURL'],
projectId: process.env['FIREBASE_projectId'],
storageBucket: process.env['FIREBASE_storageBucket'],
messagingSenderId: process.env['FIREBASE_messagingSenderId'],




Also I tried like this in keys_prod.js but I guess we can not use object in the env_var, so I changed it to the code above.



module.exports = 
firebase: process.env.FIREBASE_CONFIG



After npm run build, I created express app, define process.env's however when I run server, I am getting error because of env_vars are missing.
I tried to see logs on both front and backend console. I can see envs on node console but not in browser.
I also tried to deploy this app to heroku and firebase hosting. In both cases I added envs externally, but nothing change. (I guess there is no difference to use env_vars in localhost or remote server right ?)



Finally I tried to change keys.js (keys_prod > keys_dev)



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_dev');
else
module.exports = require('./keys_dev');



then it works, but I can find the credentials in the source code this time.










share|improve this question
























  • Can you try VUE_APP_FIREBASE_CONFIG and confirm

    – Varit J Patel
    Mar 28 at 11:27











  • keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

    – Caner Sezgin
    Mar 28 at 12:04












  • Tell me do you want to put the firebase variable in env file or .js works?

    – Varit J Patel
    Mar 28 at 12:07













1












1








1








I have been trying to deploy my firebase&vue app.
However I couldn't add firebase credentials to the env variable.



Basically this is the structure on vue.js




  • config



    ---- key.js



    ---- keys_dev.js



    ---- keys_prod.js



key.js



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_prod');
else
module.exports = require('./keys_dev');



keys_dev.js



module.exports = 
firebase:
apiKey: "*********************************",
authDomain: "*****************************",
databaseURL: "****************************",
projectId: "******************************",
storageBucket: "**************************",
messagingSenderId: "**********************",




keys_prod.js



module.exports = 
firebase:
apiKey: process.env['FIREBASE_apiKey'],
authDomain: process.env['FIREBASE_authDomain'],
databaseURL: process.env['FIREBASE_databaseURL'],
projectId: process.env['FIREBASE_projectId'],
storageBucket: process.env['FIREBASE_storageBucket'],
messagingSenderId: process.env['FIREBASE_messagingSenderId'],




Also I tried like this in keys_prod.js but I guess we can not use object in the env_var, so I changed it to the code above.



module.exports = 
firebase: process.env.FIREBASE_CONFIG



After npm run build, I created express app, define process.env's however when I run server, I am getting error because of env_vars are missing.
I tried to see logs on both front and backend console. I can see envs on node console but not in browser.
I also tried to deploy this app to heroku and firebase hosting. In both cases I added envs externally, but nothing change. (I guess there is no difference to use env_vars in localhost or remote server right ?)



Finally I tried to change keys.js (keys_prod > keys_dev)



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_dev');
else
module.exports = require('./keys_dev');



then it works, but I can find the credentials in the source code this time.










share|improve this question














I have been trying to deploy my firebase&vue app.
However I couldn't add firebase credentials to the env variable.



Basically this is the structure on vue.js




  • config



    ---- key.js



    ---- keys_dev.js



    ---- keys_prod.js



key.js



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_prod');
else
module.exports = require('./keys_dev');



keys_dev.js



module.exports = 
firebase:
apiKey: "*********************************",
authDomain: "*****************************",
databaseURL: "****************************",
projectId: "******************************",
storageBucket: "**************************",
messagingSenderId: "**********************",




keys_prod.js



module.exports = 
firebase:
apiKey: process.env['FIREBASE_apiKey'],
authDomain: process.env['FIREBASE_authDomain'],
databaseURL: process.env['FIREBASE_databaseURL'],
projectId: process.env['FIREBASE_projectId'],
storageBucket: process.env['FIREBASE_storageBucket'],
messagingSenderId: process.env['FIREBASE_messagingSenderId'],




Also I tried like this in keys_prod.js but I guess we can not use object in the env_var, so I changed it to the code above.



module.exports = 
firebase: process.env.FIREBASE_CONFIG



After npm run build, I created express app, define process.env's however when I run server, I am getting error because of env_vars are missing.
I tried to see logs on both front and backend console. I can see envs on node console but not in browser.
I also tried to deploy this app to heroku and firebase hosting. In both cases I added envs externally, but nothing change. (I guess there is no difference to use env_vars in localhost or remote server right ?)



Finally I tried to change keys.js (keys_prod > keys_dev)



if(process.env.NODE_ENV == 'production')
module.exports = require('./keys_dev');
else
module.exports = require('./keys_dev');



then it works, but I can find the credentials in the source code this time.







javascript node.js firebase vue.js environment-variables






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 10:38









Caner SezginCaner Sezgin

777 bronze badges




777 bronze badges















  • Can you try VUE_APP_FIREBASE_CONFIG and confirm

    – Varit J Patel
    Mar 28 at 11:27











  • keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

    – Caner Sezgin
    Mar 28 at 12:04












  • Tell me do you want to put the firebase variable in env file or .js works?

    – Varit J Patel
    Mar 28 at 12:07

















  • Can you try VUE_APP_FIREBASE_CONFIG and confirm

    – Varit J Patel
    Mar 28 at 11:27











  • keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

    – Caner Sezgin
    Mar 28 at 12:04












  • Tell me do you want to put the firebase variable in env file or .js works?

    – Varit J Patel
    Mar 28 at 12:07
















Can you try VUE_APP_FIREBASE_CONFIG and confirm

– Varit J Patel
Mar 28 at 11:27





Can you try VUE_APP_FIREBASE_CONFIG and confirm

– Varit J Patel
Mar 28 at 11:27













keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

– Caner Sezgin
Mar 28 at 12:04






keys_prod (vue.js) module.exports = firebase: process.env.VUE_APP_FIREBASE_CONFIG .env (node.js) VUE_APP_FIREBASE_CONFIG= "apiKey": "", "authDomain": "", "databaseURL": "", "projectId": "", "storageBucket": "", "messagingSenderId": "" Nothing changed, when I console log on node.js, I cant see env_vars. Can I use object like this ? Or should I use primitives.

– Caner Sezgin
Mar 28 at 12:04














Tell me do you want to put the firebase variable in env file or .js works?

– Varit J Patel
Mar 28 at 12:07





Tell me do you want to put the firebase variable in env file or .js works?

– Varit J Patel
Mar 28 at 12:07












1 Answer
1






active

oldest

votes


















0
















Here how you can do it.



Firstly, add dev.env to your project and add firebase variables.



FIREBASE_CONFIG: 
apiKey: "*********************************",
authDomain: "*****************************",
databaseURL: "****************************",
projectId: "******************************",
storageBucket: "**************************",
messagingSenderId: "**********************",



Import the file in dev.env.js



import merge from 'webpack-merge';
import env from './dev.env';

module.exports = merge(env,
NODE_ENV: 'development'



Now, Initialize your firebase app with



import * as firebase from 'firebase';
firebase.initializeApp(VUE_APP_FIREBASE_CONFIG)


There you go! Firebase is set up for you



Hope this helps!






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395516%2fhow-to-store-firebase-credentials-in-vue-js-projects-after-building-env-var%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0
















    Here how you can do it.



    Firstly, add dev.env to your project and add firebase variables.



    FIREBASE_CONFIG: 
    apiKey: "*********************************",
    authDomain: "*****************************",
    databaseURL: "****************************",
    projectId: "******************************",
    storageBucket: "**************************",
    messagingSenderId: "**********************",



    Import the file in dev.env.js



    import merge from 'webpack-merge';
    import env from './dev.env';

    module.exports = merge(env,
    NODE_ENV: 'development'



    Now, Initialize your firebase app with



    import * as firebase from 'firebase';
    firebase.initializeApp(VUE_APP_FIREBASE_CONFIG)


    There you go! Firebase is set up for you



    Hope this helps!






    share|improve this answer





























      0
















      Here how you can do it.



      Firstly, add dev.env to your project and add firebase variables.



      FIREBASE_CONFIG: 
      apiKey: "*********************************",
      authDomain: "*****************************",
      databaseURL: "****************************",
      projectId: "******************************",
      storageBucket: "**************************",
      messagingSenderId: "**********************",



      Import the file in dev.env.js



      import merge from 'webpack-merge';
      import env from './dev.env';

      module.exports = merge(env,
      NODE_ENV: 'development'



      Now, Initialize your firebase app with



      import * as firebase from 'firebase';
      firebase.initializeApp(VUE_APP_FIREBASE_CONFIG)


      There you go! Firebase is set up for you



      Hope this helps!






      share|improve this answer



























        0














        0










        0









        Here how you can do it.



        Firstly, add dev.env to your project and add firebase variables.



        FIREBASE_CONFIG: 
        apiKey: "*********************************",
        authDomain: "*****************************",
        databaseURL: "****************************",
        projectId: "******************************",
        storageBucket: "**************************",
        messagingSenderId: "**********************",



        Import the file in dev.env.js



        import merge from 'webpack-merge';
        import env from './dev.env';

        module.exports = merge(env,
        NODE_ENV: 'development'



        Now, Initialize your firebase app with



        import * as firebase from 'firebase';
        firebase.initializeApp(VUE_APP_FIREBASE_CONFIG)


        There you go! Firebase is set up for you



        Hope this helps!






        share|improve this answer













        Here how you can do it.



        Firstly, add dev.env to your project and add firebase variables.



        FIREBASE_CONFIG: 
        apiKey: "*********************************",
        authDomain: "*****************************",
        databaseURL: "****************************",
        projectId: "******************************",
        storageBucket: "**************************",
        messagingSenderId: "**********************",



        Import the file in dev.env.js



        import merge from 'webpack-merge';
        import env from './dev.env';

        module.exports = merge(env,
        NODE_ENV: 'development'



        Now, Initialize your firebase app with



        import * as firebase from 'firebase';
        firebase.initializeApp(VUE_APP_FIREBASE_CONFIG)


        There you go! Firebase is set up for you



        Hope this helps!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 12:25









        Varit J PatelVarit J Patel

        2,3391 gold badge9 silver badges18 bronze badges




        2,3391 gold badge9 silver badges18 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395516%2fhow-to-store-firebase-credentials-in-vue-js-projects-after-building-env-var%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript