ドメイン間問題サービス側の解決策Request header field Authorization is not allowed by Access-Control-Allow-Headers

1140 ワード

ドメイン間問題サービス側の解決策
一般的にエントランスファイルに
header('Access-Control-Allow-Origin:*');
//     
header('Access-Control-Allow-Methods:*');
//      
header('Access-Control-Allow-Headers:content-type,token,id');
header("Access-Control-Request-Headers: Origin, X-Requested-With, content-Type, Accept, Authorization");

すべて解決することができて、もしだめなら下を試してみます
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
    header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
    file_put_contents('option.txt',json_encode($_REQUEST));
    exit;
}

header('Access-Control-Allow-Origin:*');
//     
header('Access-Control-Allow-Methods:*');
//      
header('Access-Control-Allow-Headers:content-type,token,id');
header("Access-Control-Request-Headers: Origin, X-Requested-With, content-Type, Accept, Authorization");

もしまだだめなら,君は自裁しなさい.