V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
29EtwXn6t5wgM3fD
V2EX  ›  jQuery

求指点 Refused to set unsafe header "cookie"

  •  
  •   29EtwXn6t5wgM3fD · Jul 17, 2017 · 13587 views
    This topic created in 3206 days ago, the information mentioned may be changed or developed.

    物联网项目,先写好了 API,使用 JWT AUTH,token 写入 cookie,提示 Refused to set unsafe header "cookie"。
    服务器已经设置了
    header / Access-Control-Allow-Origin *
    header / Access-Control-Allow-Credentials true
    代码如下:

    	$.ajax({
    		url: "https://api.xxx.xxx/temperature/",
    		type: "GET",  
    		beforeSend: function(xhr){  
    			xhr.setRequestHeader('cookie', token)  
    		},  
    		success: function(data){  
    			alert(data);  
    		}  
    	})  
    

    求解惑

    3 replies    2017-07-18 08:26:06 +08:00
    29EtwXn6t5wgM3fD
        2
    29EtwXn6t5wgM3fD  
    OP
       Jul 18, 2017 via iPhone
    @kfll 那应该如何使用 JWT token 呢
    29EtwXn6t5wgM3fD
        3
    29EtwXn6t5wgM3fD  
    OP
       Jul 18, 2017 via iPhone
    @kfll 多谢已经找到了应该放在 Authorization Header 里
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5650 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 06:51 · PVG 14:51 · LAX 23:51 · JFK 02:51
    ♥ Do have faith in what you're doing.