skip to Main Content

I have deployed my frontend and backend both on GitHub pages. looking to add my backend URL to my frontend environments not working. the frontend login screen shows up but can’t login with out my backend running with it. I know I have to add it somewhere in the environment variables but have never done it before on GitHub.

2

Answers


  1. Chosen as BEST ANSWER

    what I had to do was host my frontend not on github pages (as it is only for static websites meaning no backend) but on netlify and my backend on a site like render that can run node backend with a run script of npm start. Then I had to get my URL given to me by render and add it to my environments in netlify to link them together.


  2. use config.js file.
    github pages does not support adding env variables directly. you can add this config file to your app to use the env varibles.

    // config.js
    const config = {
      apiUrl: 'https://api.example.com',
    };
    
    export default config;
    
    // index.js
    import config from './config.js';
    
    console.log(config.apiUrl);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search