mozilla / send

Simple, private file sharing from the makers of Firefox
https://send.firefox.com
Mozilla Public License 2.0
13.26k stars 1.57k forks source link

Immediate upload failure (something went wrong page) #1513

Open cmerola opened 4 years ago

cmerola commented 4 years ago

I got this up and running fairly quickly from the docs and insight from https://ahmedmusaad.com/self-hosting-firefox-send/, however, when it comes to uploading documents, it instantly fails to the /error page as soon as I click upload - all other file stats display correctly. My hunch is that it's storage related, though tmk I thought it was suppose to default to local storage. All seems fine except for the upload portion.

This is what the web console shows: TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at Object.pruneTokens (storage.js:213) at new <anonymous> (storage.js:38) at Object.<anonymous> (storage.js:228) at o (bootstrap:63) at Module.<anonymous> (metrics.js:1) at o (bootstrap:63) at Module.<anonymous> (app.f2f95a8e.js:29) at o (bootstrap:63) at Object.<anonymous> (app.f2f95a8e.js:29) pruneTokens @ storage.js:223 image

My Env:

Any ideas? Permissions Related? I can't locate a log file, so if someone could point that out as well, that'd be awesome.

Thanks in advance!

drum7 commented 4 years ago

I have this exact same issue both running as a normal npm app and as a container.

okyanusoz commented 4 years ago

OK. I found a solution. Open server/config.js in any editor and change this line:

fxa_required: { format: Boolean, default: true, env: 'FXA_REQUIRED' }, to:

fxa_required: { format: Boolean, default: false, env: 'FXA_REQUIRED' },

okyanusoz commented 4 years ago

It worked for me

drum7 commented 4 years ago

Me too - How'd you find the fix? Someone else posted a new 401 error with that as an ENV variable. Couldn't find it in the docs, but I'm sure that's just b/c i'm skimming. It also makes sense since they're changing how the service can be used to mandate auth...

okyanusoz commented 4 years ago

Well, let me explain, take a look at this code where the 401 error occurs:
if (config.fxa_required && !user) { ws.send( JSON.stringify({ error: 401 }) ); return ws.close(); }(taken from https://github.com/mozilla/send/blob/master/server/routes/ws.js)
So, it checks if a FXA(Firefox Account) is required and if the client is not authenticated, it gives an error.
In the configuration, Firefox Accounts are required by default but you need a client ID for that and we don't have any.
That's why this happens.

drum7 commented 4 years ago

Well, let me explain, take a look at this code where the 401 error occurs:

if (config.fxa_required && !user) { ws.send( JSON.stringify({ error: 401 }) ); return ws.close(); }(taken from https://github.com/mozilla/send/blob/master/server/routes/ws.js)

So, it checks if a FXA(Firefox Account) is required and if the client is not authenticated, it gives an error.

In the configuration, Firefox Accounts are required by default but you need a client ID for that and we don't have any.

That's why this happens.

With you - except where I saw the error in my console was...I think storage.js or something weird, leading me to think it was some undocumented storage req. I also could be remembering wrong so will have to play a bit later... You just tried to submit something and then watched the console?

In any event...thank you!

okyanusoz commented 4 years ago

I looked at the network activity and saw the 401 error

cmerola commented 4 years ago

Thanks @okyanusoz! Excited to try it out.

ioistired commented 4 years ago

I tried setting the environment variable FXA_REQUIRED to false (which is the format convict expects for boolean env vars) and it didn't help.