fix: weird HF readme accessibility
This commit is contained in:
parent
1a72a592b9
commit
7b2d0432e6
@ -156,12 +156,19 @@ function HubModelDetail() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modelData?.readme) {
|
if (modelData?.readme) {
|
||||||
setIsLoadingReadme(true)
|
setIsLoadingReadme(true)
|
||||||
fetch(modelData.readme, {
|
// Try fetching without headers first
|
||||||
headers: huggingfaceToken
|
// There is a weird issue where this HF link will return error when access public repo with auth header
|
||||||
? {
|
fetch(modelData.readme)
|
||||||
|
.then((response) => {
|
||||||
|
if (!response.ok && huggingfaceToken && modelData?.readme) {
|
||||||
|
// Retry with Authorization header if first fetch failed
|
||||||
|
return fetch(modelData.readme, {
|
||||||
|
headers: {
|
||||||
Authorization: `Bearer ${huggingfaceToken}`,
|
Authorization: `Bearer ${huggingfaceToken}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
: {},
|
return response
|
||||||
})
|
})
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((content) => {
|
.then((content) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user