为什么邮件路径需要真实检查
Cursor 的智能体擅长认证相关的代码:表单、路由、令牌处理和邮件模板。但一项改动可能通过所有测试,却仍然发出链接到 localhost 的邮件、因发件人未设置而从未送达,或者包含在任何人输入之前就过期的验证码。这些问题只有在真实邮件到达真实收件箱时才会出现。
它会构建哪种登录?
用你要求的那个,或者代码库已经在用的那个。Supabase Auth、Clerk、Firebase Authentication、Auth.js 和 Better Auth 发送的邮件各不相同:Clerk 默认发送验证码,Firebase 发送链接,Auth.js 只发送魔法链接,除非你自己实现其余部分。在提示词或项目规则中写明你想要的方式,然后测试智能体改动发出的每封邮件。各登录服务发送哪些邮件。
每次认证改动后检查
- 运行应用,在本地运行,或打开你分支的预览部署。
- 在 Proxy Mail QA 中创建地址,每个场景一个:新用户、受邀用户、密码重置。
- 走一遍改动涉及的流程,使用该地址所在行中的验证码或链接。
- 在收件箱视图中完整阅读一遍邮件:发件人、主题、措辞和每个链接。
- 在地址上记下你的发现,让它留在测试账号上。
预览或预发布部署上指向 localhost 的链接会在该行被标记。这里介绍如何在 Supabase、Firebase、Auth.js 和其他技术栈中修复。
让 Cursor 的智能体自己检查邮件
从 Cursor Directory 添加 Proxy Mail QA:Add to Cursor 会安装 MCP server 和一个技能,带智能体一步步完成注册测试。然后在 Cursor Settings 的 MCP 部分登录:在浏览器中登录 Proxy Mail QA 并选择项目,不需要复制 API 密钥。
然后用平常的话提问:“在 localhost:3000 上用一个新的 Proxy Mail QA 地址注册,并确认邮件。”智能体会创建地址、填写你的表单、等待验证码或链接,然后完成注册。如果要在 .cursor/mcp.json 中改用 API 密钥,请参阅 MCP server 设置。
适用于 Cursor 的可直接复制的提示词
List every email this app sends: sign-up confirmation, magic link, password reset, invite and email change. For each, show where it's triggered in the code, which service sends it, how its link URL is built, and how long its code or link is valid. Flag hard-coded localhost URLs.Build every link in auth emails from an environment variable for the app's public URL, with localhost only as the development default. Add the variable to .env.example and the deployment settings.The email says the code is valid for 10 minutes. Make the server enforce the same expiry, and make requesting a new code invalidate the old one.防止常见错误的项目规则
把它保存为项目规则(例如 .cursor/rules/auth-emails.mdc),这样智能体每次涉及认证时都会遵守:
When changing sign-up, login, password reset, invites or any email-sending code:- Build links from the app's public URL setting, never a hard-coded localhost.- Keep the expiry stated in an email equal to the one the server enforces.- Make single-use links and codes stop working once used or replaced.- Tell me which emails to test by hand after the change.