File tree 3 files changed +11
-4
lines changed
3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " blossom-server-ts " : patch
3
+ ---
4
+
5
+ Fix broken media upload on home page
Original file line number Diff line number Diff line change @@ -38,13 +38,15 @@ export class UploadForm extends LitElement {
38
38
39
39
this . status = "Signing..." ;
40
40
41
+ const endpoint = this . optimize ? "/media" : "/upload" ;
42
+
41
43
// create auth event
42
44
const auth = await window . nostr . signEvent ( {
43
45
kind : 24242 ,
44
46
content : "Authorize Upload" ,
45
47
created_at : unixNow ( ) ,
46
48
tags : [
47
- [ "t" , "upload" ] ,
49
+ [ "t" , optimize ? "media" : "upload" ] ,
48
50
[ "x" , hash ] ,
49
51
[ "expiration" , newExpirationValue ( ) ] ,
50
52
] ,
@@ -53,7 +55,7 @@ export class UploadForm extends LitElement {
53
55
54
56
// BUD-06 check upload
55
57
this . status = "Checking Upload..." ;
56
- const check = await fetch ( "/upload" , {
58
+ const check = await fetch ( endpoint , {
57
59
method : "HEAD" ,
58
60
headers : {
59
61
authorization,
@@ -69,7 +71,7 @@ export class UploadForm extends LitElement {
69
71
70
72
// Upload blob
71
73
this . status = "Uploading..." ;
72
- const res = await fetch ( this . optimize ? "/media" : "/upload" , {
74
+ const res = await fetch ( endpoint , {
73
75
method : "PUT" ,
74
76
body : file ,
75
77
// attach Authorization: Nostr <base64> header to request
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export function checkUpload(
24
24
// check auth
25
25
if ( opts . requireAuth ) {
26
26
if ( ! ctx . state . auth ) throw new HttpErrors . Unauthorized ( "Missing Auth event" ) ;
27
- if ( ctx . state . authType !== authType ) throw new HttpErrors . Unauthorized ( " Auth event must be 'upload'" ) ;
27
+ if ( ctx . state . authType !== authType ) throw new HttpErrors . Unauthorized ( ` Auth event must be '${ authType } '` ) ;
28
28
if ( hasUsedToken ( ctx . state . auth . id ) ) throw new HttpErrors . BadRequest ( "Auth event already used" ) ;
29
29
30
30
// BUD-06, check if hash is in auth event
You can’t perform that action at this time.
0 commit comments