0

我正在尝试使用 satellizer 为 twitter 实现登录。我正在关注卫星存储库上的示例,因此在客户端我执行以下操作:

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

在服务器端,我遵循他们的 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.

但是,当我重定向到 /authenticate URL 时,我得到一个 CORS 错误:

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

我查看了他们的 php/Laravel 示例,他们使用重定向,但对我来说不起作用。

我怎么解决这个问题?

4

1 回答 1

0

您需要在 index.php 文件中添加 Access-Control-Allow-Origin 标头。在服务器端打开 index.php 并在后面添加这一行<?php

header("Access-Control-Allow-Origin: *");
于 2015-11-03T13:20:15.730 回答