bobbingwide / react-SB

React UI for Genesis-SB theme
GNU General Public License v3.0
1 stars 0 forks source link

const BIGRAM_URL - should be determined dynamically at runtime #7

Closed bobbingwide closed 7 years ago

bobbingwide commented 7 years ago

The demoApi class ( in rest-api.js file ) needs to know the url to which the REST API requests should be directed. This is currently hardcoded in the const BIGRAM_URL as http://localhost/bigram, equivalent to http://qw/bigram.

Requirement

We need a solution that will work when the real target site is http://bigram.co.uk

Invocation method Server Type BIGRAM_URL
http://localhost:8080 webpack-dev-server Dev http://qw/bigram/
http://qw/react-SB/public index.html Dev / UT http://qw/bigram/
http://qw/bigram/react-sb-page page-react-sb-page.php Test http://qw/bigram/
http://bigram.co.uk/react-sb-page page-react-sb-page.php Prod http://bigram.co.uk/

Proposed solution

Use window.location.hostname and window.location.protocol If hostname is localhost or qw then set BIGRAM_URL to qw/bigram else set it to the hostname

bobbingwide commented 7 years ago

The initial solution appears to work on Chrome on a laptop but not on my iPad.
The daily trace summary log indicates that no REST requests are being processed.

Further investigation led to issue #8.

bobbingwide commented 7 years ago

This issue was fixed in https://github.com/bobbingwide/react-SB/commit/4faf2857604f99e3256552b7a1a575507f738157