Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/opencor/webapp.git"
},
"type": "module",
"version": "1.20260813.0",
"version": "1.20260813.1",
"engines": {
"bun": ">=1.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"./style.css": "./dist/opencor.css"
},
"version": "1.20260813.0",
"version": "1.20260813.1",
"libopencorVersion": "1.20260803.0",
"scripts": {
"build": "vite build && bun scripts/generate.version.ts",
Expand Down
16 changes: 12 additions & 4 deletions src/renderer/src/common/locCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,23 @@ export const file = (
return response.arrayBuffer();
}

// If the fetch through OpenCOR's CORS proxy failed, then throw an error to trigger the catch block below.

throw new Error(
`Failed to fetch the file through OpenCOR's CORS proxy. The server responded with a status of ${response.status}.`
`Failed to fetch the file through OpenCOR's CORS proxy. The server responded with a status of ${response.status}.`,
{
cause: response.status
}
);
})
.catch((error: unknown) => {
// A network/CORS error is an instance of TypeError in fetch. So, if this is the case then we try fetching
// the file directly otherwise we re-throw the error.
// If the fetch through OpenCOR's CORS proxy failed, then try fetching the URL directly, unless the error
// was a TypeError or an HTTP 403 or 404 error.

if (!(error instanceof TypeError)) {
if (
!(error instanceof TypeError) &&
(!(error instanceof Error) || typeof error.cause !== 'number' || ![403, 404].includes(error.cause))
) {
throw new Error(common.formatError(error));
}

Expand Down
Loading