MagicMirror
MagicMirror copied to clipboard
weather module for ukmetoffice showing cors error
Access to XMLHttpRequest at 'http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/94004601?res=3hourly&key=fribble' from origin 'http://0.0.0.0:8090' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/94004601?res=3hourly&key=fribble' from origin 'http://localhost:8090' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
{
module: "weather",
position: "top_right",
config: {
weatherProvider: "ukmetoffice",
apiBase :'http://thingproxy.freeboard.io/fetch/http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/',
locationID: "94004601",
apiKey: "fribble"
}
}
should fail with unauthorized as fribble is a bad apikey
this is the generated url request
http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/94004601?res=3hourly&key=fribble
2.17,1
The used cors-provider in darksky provider https://cors-anywhere.herokuapp.com/
seems to work (instead of http://thingproxy.freeboard.io/fetch/
).
Getting now expected 401 (have no key).
when I do this (prefix the provider generated url with the herokuapp proxy link )
https://cors-anywhere.herokuapp.com/http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/94004601?res=3hourly&key=fribble
I get a a nothing here yet page
I'm seeing a similar cors error using the envcanada weather provider.
Config.js entry:
{
module: "weather",
position: "top_left",
config: {
weatherProvider: "envcanada",
siteCode: 's0000098',
provCode: "QC",
type: "current",
showPeriod: false,
showHumidity: true,
location: "Salaberry-de-Valleyfield"
}
},
console error:
Access to XMLHttpRequest at 'https://thingproxy.freeboard.io/fetch/https://dd.weather.gc.ca/citypage_weather/xml/QC/s0000098_e.xml' from origin 'http://192.168.x.x:xxxx' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I can confirm this error. So using https://thingproxy.freeboard.io/fetch/
as cors proxy seems not to work anymore. It is difficult to find a working one, the above mentioned https://cors-anywhere.herokuapp.com/
now wants a button click in the web ui before you can use it ...
@jptrsn the above PR is merged so you could test if envcanda
works now. You have to use the develop
branch for testing this (next official release is 1.April). I would recommend to clean up (rm -rf node_modules
) and run a new npm install --only=prod
.
@sdetweil while testing this I had no problems with ukmetoffice
when running without a cors proxy. If you still have cors problems with this provider you could also test the develop
branch and add useCorsProxy: true,
in the config:
{
module: "weather",
position: "top_right",
config: {
weatherProvider: "ukmetoffice",
useCorsProxy: true,
locationID: "322942",
apiKey: "xxx"
}
},
Let me know if it works.
ok, wasn't me directly. will advise the user
I'm using a docker-based approach, so I will wait on the next production release and rebuild the image. Currently don't have any dedicated hardware for this.
o.k., if it is an option for you: the image karsten13/magicmirror:develop
contains the develop
branch of this repo ...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
this doesn't work for ukmetofficehub.. doesnt use the provider fetchData... garf..
tested ukmetofficehub
without any problems
I just tested on 2.20, develop, and it doesn't call providers/fetchData.. so can't get cors fix.
send me email, I can provide failing apikey info same userid at gmail
@sdetweil can this be closed?