fix: resolve CDN redirect before Range requests (5.0.2)#15
Merged
AthrunArthur merged 1 commit intoJun 22, 2026
Merged
Conversation
5.0.1 used redirect:'manual' to re-apply Range on redirects, but cross-origin 302 responses are opaque (HTTP status 0) so Location cannot be read. Resolve the final URL via HEAD response.url first, then issue Range against that URL directly. Co-authored-by: Cursor <cursoragent@cursor.com>
AthrunArthur
approved these changes
Jun 22, 2026
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.
概述
ERR_CANNOT_READ_TAIL,HTTP 状态码为 0(例如cdn1.dianshudata.com→cs-test.dianshudata.com)。fetchRange中使用redirect: 'manual',意图在重定向时重新携带Range头(Safari 兼容)。但跨域 302 时浏览器返回 opaque redirect(status === 0),JS 无法读取Location,手动跟跳失效。HEAD+redirect: 'follow'跟完重定向,取response.url作为真实文件地址,再对该地址直接发Range(Range 请求不再经过重定向)。Chrome/Firefox 可恢复正常,Safari 也不会在跟跳时丢失Range。改动
fetchRange.js:移除 manual 重定向循环,改回redirect: 'follow';新增resolvedFetchUrl()downloadUnsealed.js/HttpSealedFileStream.js:用headResp.url作为后续 Range 请求 URL测试
cdn1.dianshudata.com/…sealed:v5.0.1 报 HTTP 0,本分支下载成功npm run build通过5.0.2后更新宿主项目(dianshu-website、SSR)