process.env.API_KEY not working on next-on-netlify deployment

There is no news on my news website.

See the logs:

But there is a webpage with the header and footer intact.

Still getting no response payload from the news-api-endpoint.

1 Like

In your netlify UI you’ve entered your API key inside quotes such as “123422” but you don’t need the quotes the UI handles that for you so the API is thinking you’ve entered the wrong API key.

Remove the quotes surrounding your API key in the UI and then edit a file add a comment etc to the code and commit it. You must do this to trigger a proper rebuild and redeployment with the new environment variable

1 Like

Thank you. Let me see if this works. In fact I have wrapped it in quotes.

No worries remember you might need to edit the code and commit and push to GitHub to change the checksum and use the new variable.

I also recommend removing the process printing from your command now and making your deploys private OR generate a new news API key if you’re super sensitive that I have seen the key. Thanks and hope it’s sorted haha I’m literally laying in bed typing on my phone :joy::joy:

You’re lying in bed and typing?

Thank you.

The problem is resolved.

There should not be any quote marks around the value in the key-value pair in the Netlify UI.

Thank you very much.

:grinning: :grinning:

1 Like

Woo glad we finally got there! Enjoy!

Thank you.

:grinning: :grinning:

go to deploy setting => envirement varaibles and add your API_KEY and it’s values there