astrologyjs
astrologyjs copied to clipboard
Fetch error
Followed your example and got the following error, using both a test version (on localhost:3000
) and on a website (with https://
). Might you know how to work around it?
Fetch API cannot load http://www.morphemeris.com/ephemeris.php?date=1974-02-17T23%3A30Z&lat=37.4381927&lon=-79.18932.
Redirect from 'http://www.morphemeris.com/ephemeris.php?date=1974-02-17T23%3A30Z&lat=37.4381927&lon=-79.18932'
to 'https://morphemeris.com/ephemeris.php?date=1974-02-17T23%3A30Z&lat=37.4381927&lon=-79.18932'
has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access.
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I ported ephemeris.php
to a private domain, manually changed the astrologyjs.min.js
file inside node_modules
to fetch from this new file, and set the php header of this new file to allow for CORS
, Access-Control-Allow-Origin:
<?php
header( 'content-type: application/json' );
header( 'Access-Control-Allow-Origin: *' );
ini_set( 'display_errors', 0 );
With that error fixed, I now ran into the following error:
(index):1 Uncaught SyntaxError: Unexpected end of JSON input
at Object.parse (<anonymous>)
at exports.IncomingMessage.<anonymous> (astrologyjs.min.js:1)
at exports.IncomingMessage.EventEmitter.emit (events.js:96)
at endReadableNT (_stream_readable.js:920)
at afterTickTwo (index.js:27)
at Item.run (browser.js:153)
at drainQueue (browser.js:123)