29EtwXn6t5wgM3fD
V2EX  ›  jQuery

求指点 Refused to set unsafe header "cookie"

  •  
  •   29EtwXn6t5wgM3fD · Jul 17, 2017 · 13710 views
    This topic created in 3268 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   ·   3125 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 13:15 · PVG 21:15 · LAX 06:15 · JFK 09:15
    ♥ Do have faith in what you're doing.