Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
api: take the relative url root into account
Browse files Browse the repository at this point in the history
Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Jan 22, 2018
1 parent 33fd126 commit 0b7a651
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/vue-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Vue.use(VueResource);
Vue.use(EventBus);
Vue.use(Alert);

Vue.http.options.root = window.API_ROOT_URL;
Vue.http.options.root = window.API_URL;

Vue.http.interceptors.push((_request, next) => {
window.$.active = window.$.active || 0;
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def app_host
request.env["HTTP_HOST"]
end

def app_relative_url_root
ENV["RAILS_RELATIVE_URL_ROOT"] || ""
end

def app_path
File.join(app_host, app_relative_url_root)
end

def js_route
action_name = ACTION_ALIASES[controller.action_name] || controller.action_name

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ html
meta content="#205683" name="theme-color"

javascript:
window.API_ROOT_URL = '//#{app_host}';
window.API_URL = '//#{app_path}';
= javascript_include_tag(*webpack_asset_paths("application"))
= yield :js_header

Expand Down

0 comments on commit 0b7a651

Please sign in to comment.