Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting WEATHER_PROVIDER in the .env file doesn't work for master #160

Open
MattyRoy opened this issue Feb 19, 2025 · 3 comments
Open

Setting WEATHER_PROVIDER in the .env file doesn't work for master #160

MattyRoy opened this issue Feb 19, 2025 · 3 comments

Comments

@MattyRoy
Copy link

I am trying to run this in a docker container using OpenMeteo as my provider. I have the following in my .env file when I build the docker container:

HOST=0.0.0.0
PORT=3000
WEATHER_PROVIDER=OpenMeteo

However when I run the docker image I get the following error:

> os-weather-service@2.1.0 start
> node js/server


/weather/js/routes/weatherProviders/Apple.js:62
            throw "APPLE_PRIVATE_KEY environment variable is not defined.";
            ^
APPLE_PRIVATE_KEY environment variable is not defined.
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v19.8.1

I have tried changing WEATHER_PROVIDER to PWS_WEATHER_PROVIDER with the same result.

Looking at weather.ts I can see that it is trying to get the provider from the request rather than the environment variable, and since there isn't any provider specified, it defaults to Apple as the provider.

How is this supposed to work - the documentation doesn't seem up to date.

@MattyRoy MattyRoy changed the title Setting WEATHER_PROVIDER in the .env file doesn't work Setting WEATHER_PROVIDER in the .env file doesn't work for master Feb 19, 2025
@MattyRoy
Copy link
Author

Looking at the code and debugging it, the Apple weather provider constructor requires APPLE_PRIVATE_KEY to be set. This doesn't seem correct if one is not going to use Apple as your weather provider?

@rayshobby
Copy link
Member

I see. This is because on our own weather server we use Apple as default and provide our own key. We will take a look at removing this requirement -- it's not as simple as the other providers as Apple requires more key data than just a string key. With other providers, you can pass in the API key through the wto option, that way the provider and key can both be provided through the url. With Apple this is a bit more complicated.

In the meantime, the workaround is to simply delete line 17 and below in Apple.ts (in the constructor function). That should allow you to launch the service.

@MattyRoy
Copy link
Author

Thanks for the reply @rayshobby. Yes, I removed Apple as a provider entirely from my local weather.ts file before building the docker image - this works as an interim solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants