pacificclimate / pdp

The PCIC Data Portal - Server software to run the entire web application
GNU General Public License v3.0
1 stars 2 forks source link

Development / test PDP is sensitive to presence or absence of trailing slash #140

Open corviday opened 4 years ago

corviday commented 4 years ago

In the live PDP, the proxy setup means this issue can't occur. It is strictly a development issue, but it's annoying enough we should consider fixing it.

Several of the ajax URLs in the pdp are constructed by taking the current URL and "going up a level". These URLs will be incorrect if you leave off the trailing slash at the end of a URL, when you are testing on your workstation or docker. The main page will work perfectly, but functionality that depends on subsidiary URLs like catalog.json ormetadata.json will go awry in subtle ways.

For example, the usual URL for the Gridded observations portal is:

http://server/gridded_observations/map/.

The catalog URL is:

../catalog/catalog.json

If the trailing slash is present, the catalog url will be generated as:

http://server/gridded_observations/catalog/catalog.json

If the trailing slash is absent, the page will load normally, but will try to access the catalog at:

http://server/catalog/catalog.json

This will cause the dataset menu to be empty. Depending on how long it takes you to remember that this issue exists, you might spend a while chasing red herrings if you think your most recent code change caused the issue.

When I first started working on the PDP, back when the development setup and environment variables were more complicated, I lost days trying to figure out what in my setup was broken, but I'd just entered the URL wrong. Even now, it still catches me now and then (like just now).

corviday commented 4 years ago

Hm, apparently this issue can happen on the live portal. Check out the lack of data on https://data.pacificclimate.org/portal/gridded_observations/map