mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-06 21:57:48 +01:00
10 lines
527 B
JavaScript
10 lines
527 B
JavaScript
import cachedFetch from "utils/proxy/cached-fetch";
|
|
|
|
export default async function handler(req, res) {
|
|
const { latitude, longitude, units, cache, timezone } = req.query;
|
|
const degrees = units === "metric" ? "celsius" : "fahrenheit";
|
|
const timezeone = timezone ?? "auto";
|
|
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset¤t_weather=true&temperature_unit=${degrees}&timezone=${timezeone}`;
|
|
return res.send(await cachedFetch(apiUrl, cache));
|
|
}
|