introduce useCorsProxy, per default only enabled for darksky and envcanada

This commit is contained in:
Karsten Hassel
2022-01-26 19:23:08 +01:00
parent 9f9c17ea8a
commit f04dd6b6cd
9 changed files with 22 additions and 43 deletions

View File

@@ -18,6 +18,7 @@ WeatherProvider.register("darksky", {
// Set the default config properties that is specific to this provider
defaults: {
useCorsProxy: true,
apiBase: "https://api.darksky.net",
weatherEndpoint: "/forecast",
apiKey: "",
@@ -67,7 +68,7 @@ WeatherProvider.register("darksky", {
// Create a URL from the config and base URL.
getUrl() {
const units = this.units[this.config.units] || "auto";
return this.getCorsUrl() + `${this.config.apiBase}${this.config.weatherEndpoint}/${this.config.apiKey}/${this.config.lat},${this.config.lon}?units=${units}&lang=${this.config.lang}`;
return `${this.config.apiBase}${this.config.weatherEndpoint}/${this.config.apiKey}/${this.config.lat},${this.config.lon}?units=${units}&lang=${this.config.lang}`;
},
// Implement WeatherDay generator.