fix(image): 修复新增供应商生图请求的 CORS 失败#199
Closed
AiW520 wants to merge 2 commits into
Closed
Conversation
✅ Deploy Preview for ai-tu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@2040725155-star is attempting to deploy a commit to the ljquan's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

问题背景
用户新增图片供应商、选择模型并提交提示词后,任务进入生成状态,但随后报错:
Failed to fetchAPI Key、模型列表及不带额外请求头的图片生成接口均可正常调用,问题只发生在浏览器环境。
根因
图片生成链路此前会无条件向所有图片供应商请求添加
X-Request-Id,用于请求超时后的结果找回。跨域供应商的 CORS 响应没有在
Access-Control-Allow-Headers中放行该自定义请求头,导致浏览器OPTIONS预检失败。正式生图请求尚未发送,前端就收到TypeError: Failed to fetch。curl 不执行浏览器 CORS 策略,因此命令行调用成功不能证明浏览器链路正常。
修复内容
X-Request-Id限定为供应商能力,不再对所有图片供应商全局注入。onRequestSent;/log/get-request执行结果找回。回归测试
新增测试覆盖:
X-Request-Id。验证结果
drawnixTypeScript 类型检查通过git diff --check通过gpt-image-2生图成功Failed to fetch兼容性
已知仓库基线问题
仓库全量测试仍有既存的音频测试 mock 缺失导出问题;全量 lint 也存在历史错误。这些问题不在本 PR 修改文件和功能范围内,不影响本次定向测试、类型检查及生产构建结果。