This small Node/Express project uses the OpenWeatherMap API. If you see an error "Invalid OpenWeather API key. Check your OPENWEATHER_KEY in .env", follow these steps:
-
Get an API key
- Create a free account at https://home.openweathermap.org/users/sign_up
- After signing in, go to "API keys" and copy your key.
-
Add the key to your project
- Copy
.env.exampleto.envin the project root. - Replace
your_openweather_api_key_herewith the key you copied.
- Copy
-
Restart the server
- If you're running with
node server.js, stop and start it again. - Example (PowerShell):
- If you're running with
node server.js
- Verify
- Visit http://localhost:3000 and use the UI to request weather.
- If the key is still invalid, ensure there are no surrounding quotes/spaces in
.envand that your account's key is active.
If you'd like, I can also add runtime checks that print the actual key (masked) or validate it with a test request on startup. Let me know which option you prefer.