Skip to content

Commit 0c5e7fa

Browse files
Merge pull request #455 from eltrino/master
Added auth options to fetch calls
2 parents db3bd5c + c038321 commit 0c5e7fa

File tree

6 files changed

+9
-1
lines changed

6 files changed

+9
-1
lines changed

src/ducks/collections.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const putDocument = (collection, directory, filename) => (
145145
export const deleteDocument = (collection, directory, filename) => dispatch => {
146146
return fetch(documentAPIUrl(collection, directory, filename), {
147147
method: 'DELETE',
148+
credentials: 'same-origin',
148149
})
149150
.then(data => {
150151
dispatch({ type: DELETE_DOCUMENT_SUCCESS });

src/ducks/datafiles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const putDataFile = (
9898
export const deleteDataFile = (directory, filename) => dispatch => {
9999
return fetch(datafileAPIUrl(directory, filename), {
100100
method: 'DELETE',
101+
credentials: 'same-origin',
101102
})
102103
.then(data => {
103104
dispatch({ type: DELETE_DATAFILE_SUCCESS });

src/ducks/drafts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const putDraft = (mode, directory, filename = '') => (
9292
export const deleteDraft = (directory, filename) => dispatch => {
9393
return fetch(draftAPIUrl(directory, filename), {
9494
method: 'DELETE',
95+
credentials: 'same-origin',
9596
})
9697
.then(data => {
9798
dispatch({ type: DELETE_DRAFT_SUCCESS });

src/ducks/pages.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const putPage = (directory, filename) => (dispatch, getState) => {
107107
export const deletePage = (directory, filename) => dispatch => {
108108
return fetch(pageAPIUrl(directory, filename), {
109109
method: 'DELETE',
110+
credentials: 'same-origin',
110111
})
111112
.then(data => {
112113
dispatch({ type: DELETE_PAGE_SUCCESS });

src/ducks/staticfiles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const uploadStaticFiles = files => dispatch => {
4646
return fetch(staticfileAPIUrl(file.name), {
4747
method: 'PUT',
4848
body: payload,
49+
credentials: 'same-origin',
4950
})
5051
.then(data => {
5152
dispatch({ type: PUT_STATICFILE_SUCCESS });
@@ -74,6 +75,7 @@ export const uploadStaticFiles = files => dispatch => {
7475
export const deleteStaticFile = filename => dispatch => {
7576
return fetch(staticfileAPIUrl(filename), {
7677
method: 'DELETE',
78+
credentials: 'same-origin',
7779
})
7880
.then(data => {
7981
dispatch({ type: DELETE_STATICFILE_SUCCESS });

src/utils/fetch.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
* @return {Function} dispatch
1818
*/
1919
export const get = (url, action_success, action_failure, dispatch) => {
20-
return fetch(url)
20+
return fetch(url, { credentials: 'same-origin' })
2121
.then(res => res.json())
2222
.then(data =>
2323
dispatch({
@@ -52,6 +52,7 @@ export const get = (url, action_success, action_failure, dispatch) => {
5252
export const put = (url, body, action_success, action_failure, dispatch) => {
5353
return fetch(url, {
5454
method: 'PUT',
55+
credentials: 'same-origin',
5556
body,
5657
})
5758
.then(res => res.json())
@@ -88,6 +89,7 @@ export const put = (url, body, action_success, action_failure, dispatch) => {
8889
export const del = (url, action_success, action_failure, dispatch) => {
8990
return fetch(url, {
9091
method: 'DELETE',
92+
credentials: 'same-origin',
9193
})
9294
.then(data =>
9395
dispatch({

0 commit comments

Comments
 (0)