前端跨域withCredentials设置为true, 请求头携带cookie信息

会会 发表于 JS 分类,标签: 前端跨域withCredentials
描述withCredentials在同一域名下使用withCredentials属性是无效的默认值是false跨域请求需要登录认证的请求,需要携带权限信息比如cookie,JWT鉴权(authorizationheaders),配置withCredentials属性为true案例使用node起一个本地的服务http://localhost:3000运行命令(server是创建的这个js的名称)1nodeserver.js或者直接在webstorm中直接运行121.打开这个server.js===》右键===》Run'Server.js'2.再或者输入命令Ctrl+Shift+F10js代码如下123456789101112131415consthttp=require('http');consthostname='12...