Egg: 关于vue+egg的csrf问题

Created on 23 Nov 2017  ·  6Comments  ·  Source: eggjs/egg

是不是因为域不相同,所以只能把csrf关掉

Most helpful comment

csrf 校验是需要先访问页面,拿到 token 的,所以不是给 API 来校验的。

All 6 comments

所以你在问什么?

不是 可以忽略JSON格式的请求
参考 https://eggjs.org/zh-cn/core/security.html#忽略-json-请求

另外如果用axios需要注意请求头 参考 https://github.com/eggjs/egg/issues/1439#issuecomment-330410683

@atian25 我遇到问题是这样的:一开始页面是没有cookie的
qq 20171123172921
然后我发起一个请求:
qq 20171123173209
失败了,但这时页面上有了cookie
qq 20171123174009
之后的请求就都ok了,
那一开始没有cookie的时候怎么解决啊

这种挤牙膏似的提问效率很低,请提供清晰的复现步骤。

csrf 校验是需要先访问页面,拿到 token 的,所以不是给 API 来校验的。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dizhifeng picture dizhifeng  ·  3Comments

wujianling picture wujianling  ·  3Comments

Leungkingman picture Leungkingman  ·  3Comments

Azard picture Azard  ·  3Comments

zhaofinger picture zhaofinger  ·  3Comments