Response with status: 0 for URL - likely CORS issu

2019-06-03 23:43发布

I have a file that issues tokens that looks like this:

<?

header('Access-Control-Allow-Origin: *');

include "lib/autoload.php";

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('g4kg867qf29jn4tr');
Braintree_Configuration::publicKey('wtqnf5txh7372nqm');
Braintree_Configuration::privateKey('67ad648bba28812356a0d9528d0aa38c');

echo($clientToken = Braintree_ClientToken::generate());

?>

I have some angular/ionic/typescript that sends a get request to the above file:

this.http.request('http://192.168.1.131:8888/generatetoken.php')
      .subscribe(res => { 
        resolve(res.text());    
      }, err => console.log(err))

The error is:

Response with status: 0 for URL

I had this happen before and adding the header('Access ... fixed it, now it seems it is happening because of it. What do I need to change?

0条回答
登录 后发表回答