@bexis2/bexis2-core-ui 0.4.53 → 0.4.54

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.
@@ -15,7 +15,12 @@ const apiRequest = (method, url, request) => {
15
15
  const requestVerificationToken = csrfToken;
16
16
  if (method == "post" && requestVerificationToken) {
17
17
  // headers['__RequestVerificationToken'] = requestVerificationToken;
18
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
18
+ // Set content type to application/x-www-form-urlencoded if it's application/json
19
+ // because always the server expect the token in form data
20
+ const contentType = headers['Content-Type'];
21
+ if (contentType === 'application/json')
22
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
23
+ // Add the token to the request body
19
24
  request = { ...request, __RequestVerificationToken: requestVerificationToken };
20
25
  }
21
26
  //using the axios instance to perform the request that received from each http method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.53",
3
+ "version": "0.4.54",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -21,7 +21,14 @@ const apiRequest = (method, url, request) => {
21
21
 
22
22
  if (method == "post" && requestVerificationToken) {
23
23
  // headers['__RequestVerificationToken'] = requestVerificationToken;
24
- headers['Content-Type']='application/x-www-form-urlencoded';
24
+
25
+ // Set content type to application/x-www-form-urlencoded if it's application/json
26
+ // because always the server expect the token in form data
27
+ const contentType = headers['Content-Type'];
28
+ if (contentType === 'application/json')
29
+ headers['Content-Type']='application/x-www-form-urlencoded';
30
+
31
+ // Add the token to the request body
25
32
  request = {...request, __RequestVerificationToken: requestVerificationToken};
26
33
  }
27
34