client: Some minor fixups to base URL feature
* Cleanup cookie storage path * Cleanup Data URL
This commit is contained in:
parent
565027269c
commit
cbf67587e2
3 changed files with 17 additions and 6 deletions
|
@ -80,9 +80,8 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||
Some users may wish to access the service at a different base URI, such
|
||||
as `http://example.com/szuru/`, commonly when sharing multiple HTTP
|
||||
services on one domain using a reverse proxy. In this case, simply set
|
||||
`BASE_URL="/szuru/"` in the frontend container, and
|
||||
`DATA_URL="/szuru/data/"` in the backend container (unless you are hosting
|
||||
your data on a different domain).
|
||||
`BASE_URL="/szuru/"` in the frontend container (unless you are hosting your
|
||||
data on a different domain).
|
||||
|
||||
You should set your reverse proxy to proxy `http(s)://example.com/szuru` to
|
||||
`http://<internal IP or hostname of frontend container>/`. For an NGINX
|
||||
|
|
|
@ -9,6 +9,18 @@ const uri = require('./util/uri.js');
|
|||
let fileTokens = {};
|
||||
let remoteConfig = null;
|
||||
|
||||
function getCookieName() {
|
||||
const bases = document.getElementsByTagName('base');
|
||||
if (bases.length) {
|
||||
let baseHref = bases[0].href;
|
||||
baseHref = baseHref.replace('/', '');
|
||||
return 'szuru-' + baseHref;
|
||||
} else {
|
||||
return 'szuru';
|
||||
}
|
||||
}
|
||||
const cookieName = getCookieName();
|
||||
|
||||
class Api extends events.EventTarget {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -126,7 +138,7 @@ class Api extends events.EventTarget {
|
|||
}
|
||||
|
||||
loginFromCookies() {
|
||||
const auth = cookies.getJSON('auth');
|
||||
const auth = cookies.getJSON(cookieName);
|
||||
return auth && auth.user && auth.token ?
|
||||
this.loginWithToken(auth.user, auth.token, true) :
|
||||
Promise.resolve();
|
||||
|
@ -169,7 +181,7 @@ class Api extends events.EventTarget {
|
|||
this.post('/user-token/' + userName, userTokenRequest)
|
||||
.then(response => {
|
||||
cookies.set(
|
||||
'auth',
|
||||
cookieName,
|
||||
{'user': userName, 'token': response.token},
|
||||
options);
|
||||
this.userName = userName;
|
||||
|
|
|
@ -28,7 +28,7 @@ def docker_config() -> Dict:
|
|||
return {
|
||||
'debug': True,
|
||||
'show_sql': int(os.getenv('LOG_SQL', 0)),
|
||||
'data_url': os.getenv('DATA_URL', '/data/'),
|
||||
'data_url': os.getenv('DATA_URL', 'data/'),
|
||||
'data_dir': '/data/',
|
||||
'database': 'postgres://%(user)s:%(pass)s@%(host)s:%(port)d/%(db)s' % {
|
||||
'user': os.getenv('POSTGRES_USER'),
|
||||
|
|
Loading…
Reference in a new issue