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

Commit 0b7a651

Browse files
committed
api: take the relative url root into account
Signed-off-by: Miquel Sabaté Solà <[email protected]>
1 parent 33fd126 commit 0b7a651

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

app/assets/javascripts/vue-shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vue.use(VueResource);
1010
Vue.use(EventBus);
1111
Vue.use(Alert);
1212

13-
Vue.http.options.root = window.API_ROOT_URL;
13+
Vue.http.options.root = window.API_URL;
1414

1515
Vue.http.interceptors.push((_request, next) => {
1616
window.$.active = window.$.active || 0;

app/helpers/application_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ def app_host
1212
request.env["HTTP_HOST"]
1313
end
1414

15+
def app_relative_url_root
16+
ENV["RAILS_RELATIVE_URL_ROOT"] || ""
17+
end
18+
19+
def app_path
20+
File.join(app_host, app_relative_url_root)
21+
end
22+
1523
def js_route
1624
action_name = ACTION_ALIASES[controller.action_name] || controller.action_name
1725

app/views/layouts/application.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ html
2929
meta content="#205683" name="theme-color"
3030

3131
javascript:
32-
window.API_ROOT_URL = '//#{app_host}';
32+
window.API_URL = '//#{app_path}';
3333
= javascript_include_tag(*webpack_asset_paths("application"))
3434
= yield :js_header
3535

0 commit comments

Comments
 (0)