fix: urls with credentials weren't working with chrome #379
Massimo Melina committed
Oct 18, 2023 at 23:31 UTC
e238297619767f9158c43e21eff3faad73708a18
2 files changed
+7
-2
shared/api.ts
+3
-1
@@ -52,8 +52,10 @@ export function apiCall<T=any>(cmd: string, params?: Dict, options: ApiCallOptio
52
return result as T
53
}, err => {
54
stop?.()
55
- if (err?.message?.includes('fetch'))
55
+ if (err?.message?.includes('fetch')) {
56
+ console.error(err.message)
57
throw Error("Network error")
58
+ }
59
throw aborted || err
60
}).finally(() => clearTimeout(timeout)), {
61
abort() {
src/vfs.ts
+4
-1
@@ -186,8 +186,11 @@ export function hasPermission(node: VfsNode, perm: keyof VfsPerms, ctx: Koa.Cont
186
187
export function statusCodeForMissingPerm(node: VfsNode, perm: keyof VfsPerms, ctx: Koa.Context, assign=true) {
188
const ret = getCode()
189
- if (ret && assign)
189
+ if (ret && assign) {
190
ctx.status = ret
191
+ if (ret === HTTP_UNAUTHORIZED) // this is necessary to support standard urls with credentials
192
+ ctx.set('WWW-Authenticate', 'Basic') // we support basic authentication
193
+ }
194
return ret
195
196
function getCode() {