skip to Main Content

This is my code github link: https://github.com/Spale96/WeatherApi

I have changed my API key inside my VScode, but netlify still uses old API key even after I have added environment variable inside with new API key.

My question is how to update API key on github and netlify?

I have added environment variable with new API key on netlify but it doesn’t update at all.

Netlify still use wrong api which i have deleted

Netlify env added(https://i.stack.imgur.com/5KzGQ.png)

2

Answers


  1. Chosen as BEST ANSWER

    Thank's Shweta Mishra!

    Retry with the latest branch commit fixed my problem.


  2. Updating API Key on GitHub:

    • Open your code in Visual Studio Code (VS Code).
    • Make sure you’ve updated the API key in your local codebase.
    • Commit the changes to your local Git repository:
    git add .
    git commit -m "Updated API key"
    
    • Push the changes to your GitHub repository:
    git push origin main
    
    

    Updating API Key on Netlify:

    • Log in to your Netlify account.
    • Navigate to your site’s dashboard.
    • Go to "Settings" or "Site settings" (the exact wording might vary).
    • Look for an option to set environment variables.
    • Add a new environment variable with the updated API key.
    • Save the changes.

    Make sure you’re updating the environment variable for the correct site if you have multiple sites on Netlify.

    If you’ve already set the environment variable on Netlify and it’s not updating, you might need to trigger a redeployment of your site for the changes to take effect. Netlify doesn’t automatically update environment variables for existing deployments. Here’s how you can trigger a redeployment:

    In your Netlify dashboard, go to the "Deploys" section for your site.

    • Click on the "Trigger deploy" button (or similar) to manually
      initiate a new deployment.
    • After completing these steps, your updated API key should be in
      effect both on GitHub and on Netlify.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search