29EtwXn6t5wgM3fD
V2EX  ›  jQuery

求指点 Refused to set unsafe header "cookie"

  •  
  •   29EtwXn6t5wgM3fD · Jul 17, 2017 · 14094 views
    This topic created in 3421 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
    29EtwXn6t5wgM3fD
    OP
    Jul 18, 2017 via iPhone
    2
    @kfll 那应该如何使用 JWT token 呢
    29EtwXn6t5wgM3fD
    29EtwXn6t5wgM3fD
    OP
    Jul 18, 2017 via iPhone
    3
    @kfll 多谢已经找到了应该放在 Authorization Header 里
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1733 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 01:04 · PVG 09:04 · LAX 17:04 · JFK 20:04
    ♥ Do have faith in what you're doing.