Browse Source

Merge pull request #5303 from nocodb/fix/non-image-attachments-openLink

fix(nc-gui): return attachment url even fetch fails
pull/5305/head
Raju Udava 2 years ago committed by GitHub
parent
commit
2f83a3acef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/nc-gui/composables/useAttachment.ts

6
packages/nc-gui/composables/useAttachment.ts

@ -16,13 +16,17 @@ const useAttachment = () => {
} }
const sources = getPossibleAttachmentSrc(item) const sources = getPossibleAttachmentSrc(item)
for (const source of sources) { for (const source of sources) {
try {
// test if the source is accessible or not // test if the source is accessible or not
const res = await fetch(source, { method: 'HEAD' }) const res = await fetch(source, { method: 'HEAD' })
if (res.ok) { if (res.ok) {
return source return source
} }
} catch {}
} }
return null // if no source can be fetched, it could be probably blocked by CORS
// return original url or built url anyway
return item.url || `${appInfo.value.ncSiteUrl}/${item.path}`
} }
const openAttachment = async (item: Record<string, any>) => { const openAttachment = async (item: Record<string, any>) => {

Loading…
Cancel
Save