Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import ENV from 'papermerge/config/environment';
function base_url() {
/*
Returns backend's REST API base url.
base url is extracted from `window` object, which
means this method is valid only in browser environment.
Notice there is no `/` at the end of returned string.
*/
let base = `${window.location.protocol}//${window.location.host}`;
if (ENV.APP.HOST) {
// user can override BACKEND HOST by providing
// ENV.APP.HOST value
// e.g. ENV.APP.HOST = 'http://127.0.0.1:8000';
base = ENV.APP.HOST;
}
if (!ENV.APP.NAMESPACE) {
return base;
}
return `${base}/${ENV.APP.NAMESPACE}`;
}
function ws_base_url() {
/*
websockets base url
*/
let base = `ws://${window.location.host}`;
if (ENV.APP.WS_HOST) {
// user can override BACKEND HOST by providing
// ENV.APP.HOST value
// e.g. ENV.APP.HOST = 'ws://127.0.0.1:8000';