garden20 / garden-market

The market or app store. Developers will upload apps to this, and users will install apps from here.
0 stars 2 forks source link

install fails with markets using vhosts/short URLs #5

Open mandric opened 10 years ago

mandric commented 10 years ago

I can verify that the market app is returning "db_src":"http://staging.dev.medicmobile.org/market_2/_db" in http://staging.dev.medicmobile.org/markets/alpha/details/kujua-lite/json.

Is there a step I'm missing when setting up a market using couchdb rewrites and vhosts config? Do we happen to have any docs on this process?

mandric commented 10 years ago

The db_src property gets set here https://github.com/garden20/garden-market/blob/master/lib/shows.js#L74

Vhosts config looks like:

{
  "localhost:5984": "/dashboard/_design/dashboard/_rewrite/",
  "localhost:5984/dashboard": "/dashboard",
  "localhost:5984/kujua-lite": "/kujua-lite",
  "localhost:5984/markets/alpha": "/market_2/_design/market/_rewrite",
  "localhost:5984/markets/beta": "/market_1/_design/market/_rewrite",
  "localhost:5984/markets/release": "/market/_design/market/_rewrite",
  "localhost:5984/muvuku-webapp": "/muvuku-webapp/_design/muvuku-webapp/_rewrite/",
  "staging.dev.medicmobile.org": "/dashboard/_design/dashboard/_rewrite/",
  "staging.dev.medicmobile.org/dashboard": "/dashboard",
  "staging.dev.medicmobile.org/kujua-lite": "/kujua-lite",
  "staging.dev.medicmobile.org/markets/alpha": "/market_2/_design/market/_rewrite",
  "staging.dev.medicmobile.org/markets/beta": "/market_1/_design/market/_rewrite",
  "staging.dev.medicmobile.org/markets/release": "/market/_design/market/_rewrite",
  "staging.dev.medicmobile.org/muvuku-webapp": "/muvuku-webapp/_design/muvuku-webapp/_rewrite/"
}
mandric commented 10 years ago

So I think the problem comes down to market/lib/shows.js#L74 because there is no way to look at the req object and determine the original path before rewrite? I put a log(req) in there and this is what i see during an install of kujua-lite from http://staging.dev.medicmobile.org/markets-release/details/kujua-lite. Neither path nor requested_path includes the pre-rewrite info. I'm on CouchDB 1.4.0. See also https://issues.apache.org/jira/browse/COUCHDB-981

{
  "info": {
    "db_name": "market",
    "doc_count": 2,
    "doc_del_count": 0,
    "update_seq": 10,
    "purge_seq": 1,
    "compact_running": false,
    "disk_size": 10203242,
    "data_size": 4836204,
    "instance_start_time": "1393887591308247",
    "disk_format_version": 6,
    "committed_update_seq": 10
  },
  "id": "kujua-lite",
  "uuid": "95d93f1f4626910a90fa5fadc66ada1d",
  "method": "GET",
  "requested_path": [
    "details",
    "kujua-lite",
    "json?callback=jQuery171034591166279278696_1394723575583&_=1394723575895"
  ],
  "path": [
    "market",
    "_design",
    "market",
    "_show",
    "kanso_details",
    "kujua-lite"
  ],
  "raw_path": "/market/_design/market/_show/kanso_details/kujua-lite?_=1394723575895&callback=jQuery171034591166279278696_1394723575583&name=kujua-lite",
  "query": {
    "_": "1394723575895",
    "callback": "jQuery171034591166279278696_1394723575583",
    "name": "kujua-lite"
  },
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip,deflate,sdch",
    "Accept-Language": "en-US,en;q=0.8,fr;q=0.6,hi;q=0.4,id;q=0.2,ms;q=0.2,sw;q=0.2",
    "Connection": "close",
    "Cookie": "uvts=XOosDdoDSa6sTLv; i18next=sw; baseURL=; __utma=79959947.1471488410.1377193891.1394029957.1394036563.30; __utmc=79959947; __utmz=79959947.1391191983.26.14.utmcsr=m.andric.us|utmccn=(referral)|utmcmd=referral|utmcct=/; _dashboard_urls=%5B%22http%3A//192.168.213.171//%22%2C%22http%3A//192.168.213.171//dashboard/_design/dashboard/_rewrite/%22%5D; AuthSession=c2VydmljZTo1MzIxQzI3QzqDppUVGQQLk1UKxZnQTkdpXbuoBg; __utma=24134264.391440701.1394722852.1394722852.1394722852.1; __utmb=24134264.3.10.1394722852; __utmc=24134264; __utmz=24134264.1394722852.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)",
    "Host": "staging.dev.medicmobile.org",
    "Referer": "http://192.168.213.171/dashboard/_design/dashboard/_rewrite/install?app_url=http%3A%2F%2Fstaging.dev.medicmobile.org%2Fmarkets-release%2Fdetails%2Fkujua-lite",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36",
    "x-couchdb-requested-path": "/market/_design/market/_rewrite/details/kujua-lite/json?callback=jQuery171034591166279278696_1394723575583&_=1394723575895",
    "x-couchdb-vhost-path": "/details/kujua-lite/json?callback=jQuery171034591166279278696_1394723575583&_=1394723575895",
    "X-Forwarded-For": "177.205.190.58",
    "X-Real-Ip": "177.205.190.58"
  },
  "body": "undefined",
  "peer": "177.205.190.58",
  "form": {},
  "cookie": {
    "uvts": "XOosDdoDSa6sTLv",
    "i18next": "sw",
    "baseURL": "",
    "__utma": "24134264.391440701.1394722852.1394722852.1394722852.1",
    "__utmc": "24134264",
    "__utmz": "24134264.1394722852.1.1.utmcsr",
    "_dashboard_urls": "%5B%22http%3A",
    "AuthSession": "c2VydmljZTo1MzIxQzI3QzqDppUVGQQLk1UKxZnQTkdpXbuoBg",
    "__utmb": "24134264.3.10.1394722852"
  },
  "userCtx": {
    "db": "market",
    "name": "service",
    "roles": [
      "_admin"
    ]
  },
  "secObj": {
    "admins": {
      "names": [],
      "roles": []
    },
    "members": {
      "names": [],
      "roles": []
    }
  }
}