Comments (1)
今天在做node登录模块的时候,发现昨天可以设置的cookie,今天无法设置了?QAQ
然后再看看请求里面,他的header里面是有一个set-cookie,然鹅cookie里面就是没有值- -
于是疯狂百度,终于找到了一个解决问题的回答
先说明一下 ,前端发送的是post请求,node 用cors解析
实际解决
这里先放一下原文
大概的意思是,前端在发送post请求的时候,需要在请求时加上 credentials: include,来表示允许其它域来发送cookie(懵,get不会吗- -,看来还是太菜
嘛这里还是注意下,不同的ajax插件设置的方法也不太一样,比如我用的是axios插件那我是这么写的
axios.create({
withCredentials: true // 允许携带cookie
})
然后,服务端的话也要做对应的处理
js‘Access-Control-Allow-Credentials’:true
node这里的话由于我用的是cors模块所以就是这样去设置
app.use(cors({
credentials: true,
}));
(嘛 node不太好还是好好学习吧,另外感觉有关于这类的资源好少QAQ
from muse-music.
Related Issues (3)
- 关于QQ音乐的音乐资源获取的步骤 HOT 2
- 关于路由组件缓存
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from muse-music.