Skip to content

Commit

Permalink
Use relative path for navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
rioastamal committed Mar 2, 2023
1 parent 1fb507a commit 78c04b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ <h1>login</h1>
</div>
<script>
let apiBaseUrl = '{{API_BASE_URL}}';
let appBaseUrl = (window.location.protocol + '//' + window.location.hostname + window.location.pathname).replace('/login.html', '');

if (window.location.search.indexOf('logout') !== -1) {
window.localStorage.removeItem('auth_token');
window.localStorage.setItem('logged_in', false);
window.location = appBaseUrl + '/login.html';
window.location = 'login.html';
}

// AWS Cloud9 development
Expand Down Expand Up @@ -85,7 +84,7 @@ <h1>login</h1>
const response = await login($('#username').value, $('#password').value);
window.localStorage.setItem('logged_in', true);
window.localStorage.setItem('auth_token', response.token);
window.location = appBaseUrl + '/index.html';
window.location = 'index.html';
} catch (err) {
alert('Invalid username or password');
}
Expand Down
5 changes: 2 additions & 3 deletions register.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ <h1>register</h1>
</div>
<script>
let apiBaseUrl = '{{API_BASE_URL}}';
let appBaseUrl = (window.location.protocol + '//' + window.location.hostname + window.location.pathname).replace('/register.html', '');

// AWS Cloud9 development
if (apiBaseUrl.indexOf('API_BASE_URL') !== -1) {
apiBaseUrl = window.location.protocol + '//' + window.location.hostname;
}

if (window.localStorage.getItem('logged_in') === 'true') {
window.location = appBaseUrl + '/index.html';
window.location = 'index.html';
}

function $(el) {
Expand Down Expand Up @@ -122,7 +121,7 @@ <h1>register</h1>
});
console.log(response);

window.location = appBaseUrl + '/login.html';
window.location = 'login.html';
} catch (err) {
alert(err);
}
Expand Down

0 comments on commit 78c04b1

Please sign in to comment.