Skip to content

Commit

Permalink
added base url constant
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySunSyn committed Jul 21, 2016
1 parent 32dbb83 commit af98353
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ee-api-behavior

EEApiBehavior
EEApiBehavior

# Production env
Needs to run on port 80

# Development env
Needs to run on a different port than 80
20 changes: 19 additions & 1 deletion ee-api-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
value: '/'
},

DEVELOPMENT_API_BASE_URL: {
type: String,
value: '/api/'
},

PRODUCTION_API_BASE_URL: {
type: String,
value: '/api/'
},

initialized: {
type: Boolean,
value: false
Expand Down Expand Up @@ -108,7 +118,15 @@
},

_configureAjax: function(request) {
request.url = this.url;
var is_production = (window.location.port === '');
var full_url = ''
if (is_production) {
full_url = this.PRODUCTION_API_BASE_URL + this.url;
} else {
full_url = this.DEVELOPMENT_API_BASE_URL + this.url;
}

request.url = full_url;
request.body = this.item;
request.contentType = this.contentType;
request.withCredentials = this.withCredentials;
Expand Down

0 comments on commit af98353

Please sign in to comment.