-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{ message: "Not Found" } when settings COMPANION_PATH="/" #4271
Comments
Hi, my gut feeling is you misconfigured your app or used the wrong credentials. |
I doubt it since i copy and pasted. But here's some proof if that helps. Does the dropbox api need to be in production or something? Or my Nodejs or dropbox version? |
Hi. what's the page that you arrive at that gives you the |
Below. I don't know if this is a security risk, but that dropbox account has nothing. |
the problem is that express is returning 404 ("not found") due to the url not being recognized (as seen from your example code). I think you have a possible error in your code, in particular where you initialize companion the 401 error is expected btw (because you're not yet authenticated) - it's not a problem and unrelated to this issue. |
closing due to not response |
I faced exactly the same scenario, and after several days of trial and error found out that This is seriously mind blowing and nearly impossible to debug in a normal way, as there's not a single hint in docs or logs why 404 is returned when Once again, this is not a misconfiguration in proxy or express app, as identical behaviour is observed with basic Sample requests to localhost for sake of clarity: $ # COMPANION_PATH unset
$ curl http://localhost:3030/connect/dropbox
Found. Redirecting to https://www.dropbox.com/oauth2/authorize?client_id=lalalafafafa&response_type=code&redirect_uri=https%3A%2F%2Fu1.domain.com%2F%2Fdropbox%2Fredirect&token_access_type=offline%
$ # COMPANION_PATH="/"
$ curl http://localhost:3030/connect/dropbox
{"message":"Not Found"}%
$ # COMPANION_PATH="/foobar"
$ curl http://localhost:3030/foobar/connect/dropbox
Found. Redirecting to https://www.dropbox.com/oauth2/authorize?client_id=lalalafafafa&response_type=code&redirect_uri=https%3A%2F%2Fu1.domain.com%2F%2Ffoobar%2Fdropbox%2Fredirect&token_access_type=offline%
Hope it helps someone and gets mentioned in the docs. I really need a drink now. |
Haven't confirmed myself, but we should confirm this as this would be a bug. |
Just tested locally and with |
If you try out https://uppy.io/examples/ then it uses a live Companion server on "/" as well. Can reopen if it turns out to be a bug. |
I used vanilla companion + My express setup: import { app as companion, socket } from '@uppy/companion'
import dotenv from 'dotenv'
import express from 'express'
import bodyParser from 'body-parser'
import session from 'express-session'
import { createClient } from 'redis'
import RedisStore from 'connect-redis'
dotenv.config()
const app = express()
app.use(bodyParser.json())
const redisClient = createClient({
port: 6379,
url: process.env.COMPANION_REDIS_URL,
})
await redisClient.connect().catch(console.error)
// NOT FOR PRODUCTION
// app.use(expressSession({
// secret: process.env.COMPANION_SECRET,
// cookie: { maxAge: 43200 }}))
app.use(session({
store: new RedisStore({ client: redisClient, prefix: 'uppy' }),
secret: process.env.COMPANION_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
secure: true, // if true only transmit cookie over https
httpOnly: false, // if true prevent client side JS from reading the cookie
maxAge: 1000 * 60 * 24 * 30 // session max age in miliseconds
}
}))
const companionOptions = {
providerOptions: {
dropbox: {
key: process.env.COMPANION_DROPBOX_KEY,
secret: process.env.COMPANION_DROPBOX_SECRET,
},
},
uploadUrls: ['(\\w+).domain.com(:[0-9]+)?'],
server: {
host: 'u1.domain.com',
validHosts: ['(\\w+).domain.com(:[0-9]+)?'],
protocol: 'https',
// path: '/', -- THIS BREAKS companion!!!!
oauthDomain: 'u1.domain.com',
implicitPath: '/uppy'
},
corsOrigins: new RegExp('^https://(.*.)?domain.com(:\\d+)?'),
allowLocalUrls: false,
filePath: './output',
secret: process.env.COMPANION_SECRET,
redisUrl: process.env.COMPANION_REDIS_URL,
}
app.use(companion(companionOptions).app)
const port = process.env.COMPANION_PORT || 3020
const server = app.listen(port, () => {
console.log('Companion listening on port', port)
})
socket(server) |
see discussions in transloadit/uppy#4271
When I set
I see in companion log:
So I think there is indeed a bug here (notice the double slashes). I think it makes sense to throw an error if the user tries to set |
* crash if trying to set path to / fixes #4271 * Update packages/@uppy/companion/src/config/companion.js
Initial checklist
Link to runnable example
No response
Steps to reproduce
And my uppy code is
My companion app code is below with the dropbox keys omitted
"@uppy/core": "^1.20.1",
"@uppy/dropbox": "^1.4.19",
"@uppy/companion": "^0.15.0",
Expected behavior
Proceed with grabbing the files properly on uppy.
Actual behavior
I clicked on Connect to Dropbox and it authenticates perfectly all the way, but arrives to a page that outputs below.
When i click the Dropbox icon on the uppy dashboard, i see this error on the console
![image](https://user-images.githubusercontent.com/16615124/211686563-c99a38f3-8ae3-4449-8711-ea95ddd03482.png)
The text was updated successfully, but these errors were encountered: