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

api: take the relative url root into account #1610

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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