payload 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin/api.js CHANGED
@@ -2,13 +2,14 @@ import qs from 'qs';
2
2
  export const requests = {
3
3
  get: (url, params = {}) => {
4
4
  const query = qs.stringify(params, { addQueryPrefix: true });
5
- return fetch(`${url}${query}`);
5
+ return fetch(`${url}${query}`, { credentials: 'include' });
6
6
  },
7
7
  post: (url, options = { headers: {} }) => {
8
8
  const headers = options && options.headers ? { ...options.headers } : {};
9
9
  const formattedOptions = {
10
10
  ...options,
11
11
  method: 'post',
12
+ credentials: 'include',
12
13
  headers: {
13
14
  ...headers,
14
15
  },
@@ -20,6 +21,7 @@ export const requests = {
20
21
  const formattedOptions = {
21
22
  ...options,
22
23
  method: 'put',
24
+ credentials: 'include',
23
25
  headers: {
24
26
  ...headers,
25
27
  },
@@ -31,6 +33,7 @@ export const requests = {
31
33
  const formattedOptions = {
32
34
  ...options,
33
35
  method: 'PATCH',
36
+ credentials: 'include',
34
37
  headers: {
35
38
  ...headers,
36
39
  },
@@ -39,12 +42,14 @@ export const requests = {
39
42
  },
40
43
  delete: (url, options = { headers: {} }) => {
41
44
  const headers = options && options.headers ? { ...options.headers } : {};
42
- return fetch(url, {
45
+ const formattedOptions = {
43
46
  ...options,
44
47
  method: 'delete',
48
+ credentials: 'include',
45
49
  headers: {
46
50
  ...headers,
47
51
  },
48
- });
52
+ };
53
+ return fetch(url, formattedOptions);
49
54
  },
50
55
  };
@@ -34,6 +34,7 @@ const Autosave = ({ collection, global, id, publishedDocUpdatedAt }) => {
34
34
  const createCollectionDoc = useCallback(async () => {
35
35
  const res = await fetch(`${serverURL}${api}/${collection.slug}?locale=${locale}&fallback-locale=null&depth=0&draft=true`, {
36
36
  method: 'POST',
37
+ credentials: 'include',
37
38
  headers: {
38
39
  'Content-Type': 'application/json',
39
40
  },
@@ -81,6 +82,7 @@ const Autosave = ({ collection, global, id, publishedDocUpdatedAt }) => {
81
82
  setTimeout(async () => {
82
83
  const res = await fetch(url, {
83
84
  method,
85
+ credentials: 'include',
84
86
  headers: {
85
87
  'Content-Type': 'application/json',
86
88
  },
@@ -35,7 +35,7 @@ const RelationshipField = (props) => {
35
35
  const collection = collections.find((coll) => coll.slug === relation);
36
36
  const fieldToSearch = ((_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.useAsTitle) || 'id';
37
37
  const searchParam = searchArg ? `&where[${fieldToSearch}][like]=${searchArg}` : '';
38
- const response = await fetch(`${serverURL}${api}/${relation}?limit=${maxResultsPerRequest}&page=${lastLoadedPageToUse}&depth=0${searchParam}`);
38
+ const response = await fetch(`${serverURL}${api}/${relation}?limit=${maxResultsPerRequest}&page=${lastLoadedPageToUse}&depth=0${searchParam}`, { credentials: 'include' });
39
39
  if (response.ok) {
40
40
  const data = await response.json();
41
41
  if (data.docs.length > 0) {
@@ -111,7 +111,7 @@ const RelationshipField = (props) => {
111
111
  }, [search]);
112
112
  const addOptionByID = useCallback(async (id, relation) => {
113
113
  if (!errorLoading && id !== 'null') {
114
- const response = await fetch(`${serverURL}${api}/${relation}/${id}?depth=0`);
114
+ const response = await fetch(`${serverURL}${api}/${relation}/${id}?depth=0`, { credentials: 'include' });
115
115
  if (response.ok) {
116
116
  const data = await response.json();
117
117
  addOptions({ docs: [data] }, relation);
@@ -87,7 +87,7 @@ const Relationship = (props) => {
87
87
  if (optionFilters === null || optionFilters === void 0 ? void 0 : optionFilters[relation]) {
88
88
  query.where.and.push(optionFilters[relation]);
89
89
  }
90
- const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`);
90
+ const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`, { credentials: 'include' });
91
91
  if (response.ok) {
92
92
  const data = await response.json();
93
93
  if (data.docs.length > 0) {
@@ -203,7 +203,7 @@ const Relationship = (props) => {
203
203
  limit: ids.length,
204
204
  };
205
205
  if (!errorLoading) {
206
- const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`);
206
+ const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(query)}`, { credentials: 'include' });
207
207
  const collection = collections.find((coll) => coll.slug === relation);
208
208
  if (response.ok) {
209
209
  const data = await response.json();
@@ -26,7 +26,7 @@ const UploadInput = (props) => {
26
26
  useEffect(() => {
27
27
  if (typeof value === 'string' && value !== '') {
28
28
  const fetchFile = async () => {
29
- const response = await fetch(`${serverURL}${api}/${relationTo}/${value}`);
29
+ const response = await fetch(`${serverURL}${api}/${relationTo}/${value}`, { credentials: 'include' });
30
30
  if (response.ok) {
31
31
  const json = await response.json();
32
32
  setFile(json);
@@ -84,12 +84,12 @@ export const DocumentInfoProvider = ({ children, global, collection, id, }) => {
84
84
  });
85
85
  }
86
86
  if (shouldFetch) {
87
- let publishedJSON = await fetch(publishedFetchURL).then((res) => res.json());
87
+ let publishedJSON = await fetch(publishedFetchURL, { credentials: 'include' }).then((res) => res.json());
88
88
  if (collection) {
89
89
  publishedJSON = (_a = publishedJSON === null || publishedJSON === void 0 ? void 0 : publishedJSON.docs) === null || _a === void 0 ? void 0 : _a[0];
90
90
  }
91
91
  if (shouldFetchVersions) {
92
- versionJSON = await fetch(`${versionFetchURL}?${qs.stringify(versionParams)}`).then((res) => res.json());
92
+ versionJSON = await fetch(`${versionFetchURL}?${qs.stringify(versionParams)}`, { credentials: 'include' }).then((res) => res.json());
93
93
  if (publishedJSON === null || publishedJSON === void 0 ? void 0 : publishedJSON.updatedAt) {
94
94
  const newerVersionParams = {
95
95
  ...versionParams,
@@ -106,7 +106,7 @@ export const DocumentInfoProvider = ({ children, global, collection, id, }) => {
106
106
  },
107
107
  };
108
108
  // Get any newer versions available
109
- const newerVersionRes = await fetch(`${versionFetchURL}?${qs.stringify(newerVersionParams)}`);
109
+ const newerVersionRes = await fetch(`${versionFetchURL}?${qs.stringify(newerVersionParams)}`, { credentials: 'include' });
110
110
  if (newerVersionRes.status === 200) {
111
111
  unpublishedVersionJSON = await newerVersionRes.json();
112
112
  }
@@ -18,7 +18,7 @@ const Verify = ({ collection }) => {
18
18
  const [verifyResult, setVerifyResult] = useState(null);
19
19
  useEffect(() => {
20
20
  async function verifyToken() {
21
- const result = await fetch(`${serverURL}/api/${collectionSlug}/verify/${token}`, { method: 'POST' });
21
+ const result = await fetch(`${serverURL}/api/${collectionSlug}/verify/${token}`, { method: 'POST', credentials: 'include' });
22
22
  setVerifyResult(result);
23
23
  }
24
24
  verifyToken();
@@ -39,7 +39,7 @@ const CompareVersion = (props) => {
39
39
  });
40
40
  }
41
41
  const search = qs.stringify(query);
42
- const response = await fetch(`${baseURL}?${search}`);
42
+ const response = await fetch(`${baseURL}?${search}`, { credentials: 'include' });
43
43
  if (response.ok) {
44
44
  const data = await response.json();
45
45
  if (data.docs.length > 0) {
@@ -27,6 +27,7 @@ const Auth = (props) => {
27
27
  const unlock = useCallback(async () => {
28
28
  const url = `${serverURL}${api}/${slug}/unlock`;
29
29
  const response = await fetch(url, {
30
+ credentials: 'include',
30
31
  headers: {
31
32
  'Content-Type': 'application/json',
32
33
  },
@@ -25,7 +25,7 @@ export const RelationshipProvider = ({ children }) => {
25
25
  limit: 250,
26
26
  };
27
27
  const query = querystring.stringify(params, { addQueryPrefix: true });
28
- const result = await fetch(`${url}${query}`);
28
+ const result = await fetch(`${url}${query}`, { credentials: 'include' });
29
29
  if (result.ok) {
30
30
  const json = await result.json();
31
31
  if (json.docs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "author": {