Closed silver-dragon closed 2 years ago
This is due to a CORS issue:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=REDACTED&magicKey=REDACTED&f=json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400.
I'm not up to speed on these problems so I don't have a resolution per se. But a very crude workaround is if you go to the URL you see in the dev console, you can paste that JSON response into https://github.com/netbymatt/ws4kp/blob/52efea0b6755573681a4d10ad91dc31d89c474f7/server/scripts/index.js#L177-L183
index 5a42116..56f3605 100644
--- a/server/scripts/index.js
+++ b/server/scripts/index.js
@@ -174,13 +174,16 @@ const index = (() => {
if (overrides[suggestion.value]) {
doRedirectToGeometry(overrides[suggestion.value]);
} else {
- const data = await utils.fetch.json('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find', {
- data: {
- text: suggestion.value,
- magicKey: suggestion.data,
- f: 'json',
- },
- });
+ const data = {
+ spatialReference: { wkid: REDACTED, latestWkid: REDACTED },
+ locations: [{
+ name: 'REDACTED',
+ extent: {
+ xmin: REDACTED, ymin: REDACTED, xmax: REDACTED, ymax: REDACTED,
+ },
+ feature: { geometry: { x: REDACTED, y: REDACTED }, attributes: { Score: 100, Addr_Type: 'Postal' } },
+ }],
+ };
const loc = data.locations[0];
if (loc) {
I think this would be fixed if SSL was enabled. Is it possible to enable ssl with node?
I think there are two separate issues to deal with here.
@gtxaspec Yes, you can use SSL with node. But it becomes messy because you have to create a self-signed certificate and then install that certificate in your browser. You can find npm packages and plenty of tutorials on how to accomplish this. But it's my goal to have this run locally without any special workarounds.
Server Environment: Fedora Server 36 VM on Proxmox Firewall disabled, SELINUX Disabled Node 16.14.0 NPM 8.19.2
Client Environment: Firefox 105.0.1 (https://weatherstar.netbymatt.com/ runs fine in this same browser)
Steps:
node install package.json
node index.js
Problem: Entering in any location and clicking go does nothing. The display never refreshes and just remains at:
WeatherStar 4000+ Enter your location above to continue
I am not sure if I have installed correctly, maybe there is some dependency I am missing or maybe a config file setup I don't know about. Or maybe its a bug. Not sure So this could be either a bug report or a request for a more detailed install guide.