🐛 修复验证码跨域Cookie传递问题
## 问题描述 验证码在生产环境(https://cs.workyai.cn)一直提示"验证码已过期" ## 根本原因 axios默认不携带credentials(包括cookies),导致: 1. 验证码生成时的session cookie无法被浏览器保存 2. 登录时无法读取到验证码session 3. SessionID不一致导致验证失败 ## 修复方案 在mounted钩子中添加axios全局配置: ```javascript axios.defaults.withCredentials = true; ``` 这样所有axios请求都会携带cookies,包括: - 验证码生成请求 - 登录验证请求 - 所有其他API请求 ## 配合后端配置 后端已配置: - CORS: credentials: true - Session cookie: sameSite: 'lax' - Session: saveUninitialized: true ## 测试说明 1. 清除浏览器Cookie 2. 访问 https://cs.workyai.cn 3. 输错密码2次触发验证码 4. 输入验证码应该能正常通过 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2131,9 +2131,12 @@ handleDragLeave(e) {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// 配置axios全局设置 - 确保验证码session cookie正确传递
|
||||
axios.defaults.withCredentials = true;
|
||||
|
||||
// 初始化调试模式状态
|
||||
this.debugMode = localStorage.getItem('debugMode') === 'true';
|
||||
|
||||
|
||||
// 阻止全局拖拽默认行为(防止拖到区域外打开新页面)
|
||||
window.addEventListener("dragover", (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user