phpangularjstwittersatellizer

Angularjs Satellizer Twitter login CORS error on redirect


I'm trying to implement a login with satellizer for twitter. I'm following the examples on the satellizer repository, so on client-side i do the following:

$auth.authenticate('twitter')
     .then(function (res) {
           console.log(res);
     });

And on server-side i follow their login flow for oauth 1.0:

Client: Open a popup window via $auth.authenticate('provider name').
Client: Unlike OAuth 2.0, you cannot go directly to the authentication screen without a valid request token.
Client: The OAuth 1.0 flow starts with the GET request to /auth/provider inside the popup.
Server: Check if URL contains oauth_token and oauth_verifier parameters.
Sever: Initially it does not, so send an OAuth signed POST request to the /request_token URL.
Server: Redirect to the /authenticate URL with a valid request token.

But, when i get to redirect to the /authenticate URL i get a CORS error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access.

I looked on their example for php/Laravel and they use redirect, but for me is not working.

How can i solve this problem?


Solution

  • You need to add the Access-Control-Allow-Origin header in your index.php file. In server side open index.php and add this line after <?php:

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