We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug
path option for server is broken. You can't start server with path other than default
When you start server like this
return db.server({ path: '/db2', // (optional) port, // (optional) cors: true // (optional), enable CORS-headers });
You can access express-pouchdb url /db2 but you can't access collections urls like /db2/mycollectionname because of error
/db2
/db2/mycollectionname
{ "error": "not_found", "reason": "no_db_file" }
I think it's because of this line https://github.com/pubkey/rxdb/blob/master/src/plugins/server.js#L58
where /db/ string is hardcoded instead of the use of path value const toFull = req.originalUrl.replace('/db/' + colName, '/db/' + to);
/db/
const toFull = req.originalUrl.replace('/db/' + colName, '/db/' + to);
Second thing is that in tunnelCollectionPath function / is added to path without checking path value so for example you can't use just / as a path.
tunnelCollectionPath
/
I was able to fix it quickly with this changed code:
function tunnelCollectionPath(db, path, app, colName) { db[colName].watchForChanges(); const pathWithSlash = path.endsWith('/') ? path : path + '/'; app.use(pathWithSlash + colName, function (req, res, next) { if (req.baseUrl === pathWithSlash + colName) { var to = normalizeDbName(db) + '-rxdb-0-' + colName; var toFull = req.originalUrl.replace(pathWithSlash + colName, pathWithSlash + to); req.originalUrl = toFull; } next(); }); }
Should I create a PR for this?
The text was updated successfully, but these errors were encountered:
FIX(server-plugin) #1447 custom server path not working
80502ee
@dstudzinski thx for reporting. I fixed this and added some tests.
Sorry, something went wrong.
No branches or pull requests
Case
Bug
Issue
path option for server is broken. You can't start server with path other than default
Info
Code
When you start server like this
You can access express-pouchdb url
/db2
but you can't access collections urls like/db2/mycollectionname
because of errorI think it's because of this line https://github.com/pubkey/rxdb/blob/master/src/plugins/server.js#L58
where
/db/
string is hardcoded instead of the use of path valueconst toFull = req.originalUrl.replace('/db/' + colName, '/db/' + to);
Second thing is that in
tunnelCollectionPath
function/
is added to path without checking path value so for example you can't use just/
as a path.I was able to fix it quickly with this changed code:
Should I create a PR for this?
The text was updated successfully, but these errors were encountered: