V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
shengyu
V2EX  ›  jQuery

求指点 Refused to set unsafe header "cookie"

  •  
  •   shengyu · 2017-07-17 22:32:52 +08:00 · 12999 次点击
    这是一个创建于 2446 天前的主题,其中的信息可能已经有所发展或是发生改变。

    物联网项目,先写好了 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 条回复    2017-07-18 08:26:06 +08:00
    kfll
        1
    kfll  
       2017-07-17 22:52:01 +08:00   ❤️ 1
    shengyu
        2
    shengyu  
    OP
       2017-07-18 08:03:37 +08:00 via iPhone
    @kfll 那应该如何使用 JWT token 呢
    shengyu
        3
    shengyu  
    OP
       2017-07-18 08:26:06 +08:00 via iPhone
    @kfll 多谢已经找到了应该放在 Authorization Header 里
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3348 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 10:43 · PVG 18:43 · LAX 03:43 · JFK 06:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.