Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit b92f3df

Browse files
memorymxschmitt
authored andcommitted
pass credentials with AJAX requests (#104)
This is necessary for identity-aware proxies to work.
1 parent 45bb3bb commit b92f3df

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

static/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class BaseComponent extends Component {
3030
}
3131

3232
componentDidMount() {
33-
fetch('/api/v1/info')
33+
fetch('/api/v1/info', {credentials: 'include'})
3434
.then(d => d.json())
3535
.then(info => this.setState({ info }))
3636
.then(() => this.checkAuth())
@@ -42,6 +42,7 @@ export default class BaseComponent extends Component {
4242
if (token) {
4343
fetch('/api/v1/auth/check', {
4444
method: 'POST',
45+
credentials: 'include',
4546
body: JSON.stringify({
4647
Token: token
4748
}),

static/src/util/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import toastr from 'toastr'
22

33
export default class UtilHelper {
44
static deleteEntry(url, cb) {
5-
fetch(url)
5+
fetch(url, {credentials: "include"})
66
.then(res => res.ok ? res.json() : Promise.reject(res.json()))
77
.then(cb())
88
.catch(e => this._reportError(e, "delete entry"))
99
}
1010
static _constructFetch(url, body, cbSucc, cbErr) {
1111
fetch(url, {
1212
method: "POST",
13+
credentials: "include",
1314
body: JSON.stringify(body),
1415
headers: {
1516
'Authorization': window.localStorage.getItem('token'),
@@ -45,6 +46,7 @@ export default class UtilHelper {
4546
}
4647
static getRecentURLs(cbSucc) {
4748
fetch('/api/v1/protected/recent', {
49+
credentials: "include",
4850
headers: {
4951
'Authorization': window.localStorage.getItem('token'),
5052
'Content-Type': 'application/json'
@@ -54,4 +56,4 @@ export default class UtilHelper {
5456
.then(res => cbSucc ? cbSucc(res) : null)
5557
.catch(e => this._reportError(e, "recent"))
5658
}
57-
}
59+
}

0 commit comments

Comments
 (0)