phpCAS 注销失败,因为 CORS "Access-Control-Allow-Origin"不存在



我有一个带有Angular 4的正面,要连接我使用的phpcas,我将其放在文件夹/后端与前部相同的位置。

在我的正面,我的index.html来自angular的ins,有一个index.php文件,首先启动,并在调用我的身份验证后包括index.html。

随后的身份验证可以按预期工作,但是每当我想断开连接时,我都会以以下方式称呼我的后端:

在前面断开连接按钮(Angular(

logoutCerbere() {
    return this._http.get("./backend/logout.php").subscribe(data => {
       console.log("Disconnected")
   })
}

logout.php

require_once 'init.inc.php';
if (phpCAS::isAuthenticated()) {
    phpCAS::logout();
    session_destroy();
    session_unset();
} else {
    header('HTTP/1.0 401 Unauthorized');
    echo 'HTTP/1.0 401 Unauthorized';    
}

init.inc.php

<?php
require_once 'CAS-1.3.6/CAS.php';
$CAS_HOST = '*******/****';
$CAS_CONTEXT = '/cas/public/';
//$cas_server_ca_cert_path = '/path/to/cachain.pem';
//phpCAS::setCasServerCACert($cas_server_ca_cert_path);
phpCAS::client(CAS_VERSION_2_0, $CAS_HOST, 443, $CAS_CONTEXT);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
?>

我遇到了一个CORS错误,说"相同的来源策略在...(原因:CORS Header'访问权限-Control-allow-Origin'Mistist'Missove'Missove'Missect(中

我不明白的是我是从我的服务器称呼的(因为我要求获取我的PHP文件,并且我的连接工作完全相同(,因此不应有CORS请求。

我在那里错过了什么?

我缺少的是:

  • 确实是PHP,因此没有CORS,但是一旦我们包括了,它是HTML/Front域

  • Getuser只是从本地存储中检索数据,因此不涉及CORS

  • 当我想提出断开请求时,请求提出前面,这意味着CORS会干预。

我只需放置<a href="backend/logout.php">Disconnect</a>就可以解决它。

这意味着PHP是运行服务器端,并且不会涉及CORS。

相关内容

最新更新