Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Pouchdb Fauxton path mismatch via Reverse Proxy #431
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.
Fauxton's logic incorrectly calculates the db resource path at
This is possibly because express itself thinks the root path is
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.
However, overall mounting Pouchdb Fauxton anywhere except
Is 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/.