-
Notifications
You must be signed in to change notification settings - Fork 154
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
Pouchdb Fauxton path mismatch via Reverse Proxy #431
Comments
Its kind of a shame this still hasn't been looked at. Not downing anyone's work, just seems like a non-starter for so many people using express. including my own. |
For reference for my (Lambda) case a workaround is probably to create a route from a dedicated domain, so the resource paths aren't fudged. But that was the effort (and cost) I wanted to avoid given ideally I wanted to spawn multiple ephemeral DBs. |
This has been fixed upstream: apache/couchdb-fauxton#1078 |
I ran into the same problem and I was able to use express to "hot patch" Fauxton js (patch for [email protected]):
Pretty ugly, but makes it work until the upstream fix makes its way to a new pouchdb release... |
Hi all and thanks for your work on Pouchdb! It was a really exciting discovery for me, and I am hoping to do great things!
Unfortunately, the bundled version of Fauxton still seems to suffer from apache/couchdb-fauxton#944 meaning it cannot function when the express app is routed via a Reverse Proxy (e.g. Amazon API Gateway). Otherwise it would be perfect for my case.
Because of the incorrect resource paths from that bug, only the left bar of Fauxton appears, and none of the controls work. My pouchdb NodeJS app works when locally hosted, but not when mapped to the path /dev/ through a reverse proxy.
I would be glad of any pointers how to solve this issue the right way with the fewest hacks. See the Chrome inspector screenshot below for the mismatched URLs.
Fauxton's logic incorrectly calculates the db resource path at
/
and authentication resource path at/_session
causing the failures shown above. The logic doesn't take account of the mount point/dev/
. Fauxton should in fact have retrieved the db resource from/dev/
and hit/dev/_session
for authentication.This is possibly because express itself thinks the root path is
/
, before the reverse proxy gets its hands on it and maps it to/dev/
. The URL the pouchdb-server can see(through express) cannot be used by an external HTTP client.I am happy to make the URL resource path explicit in my code if there is some way to do so. I have no choice but to use a reverse proxy for my case without a LOT of extra engineering.
FIXES OUT THERE?
Some work on the authentication plugin looks like it might have addressed the issue with _session being routed incorrectly.
pouchdb-community/pouchdb-authentication#215
However, overall mounting Pouchdb Fauxton anywhere except
/_utils/
seems like an unsolved issue since the last comment on #260 17 Oct 2018Is this because the fix hasn't been bundled through pouchdb-fauxton yet? Or doesn't the fix work in my case (where a reverse proxy is changing the mount point from the resource path express can see).
Alternatively perhaps there's a trivial way to work around the issue meaning noone has had a major reason to work on it. Is following #183 (comment) the right way forward?
I recall a comment about possibly adding a config property that can be set to tell pouchdb what its external root URL is, but I can't find that property.
Luckily the database endpoints themselves seem to be fine. However, key endpoints for the Fauxton SPA have incorrectly mapped URLs .
BACKGROUND - MY USE CASE
I encountered the issue when mounting pouchdb-server via aws-serverless-express on an AWS Lambda. Spent a long time trying to debug what I assumed was a Lambda event-translation, CORS or Mime Type issue. Finally found AWS API Gateway was mounting handlers via a reverse-proxy at servername.awsthingy.com/dev/.
The text was updated successfully, but these errors were encountered: