strapi-custom-auth 1.2.35 → 1.2.37

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.
@@ -70,13 +70,24 @@ const originalFetch = window.fetch;
70
70
  const fetchInterceptor = (storage) => {
71
71
  window.fetch = async (input, init = {}) => {
72
72
  console.log("---input---", JSON.stringify(input));
73
+ console.log("---init---", JSON.stringify(init));
73
74
  const url = input instanceof Request ? input.url : input;
74
75
  console.log("---url---", url);
75
76
  const byPass = init.headers ? await init.headers.get("x-by-pass") : false;
76
77
  if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
77
78
  console.log("---skip renewal---");
78
79
  try {
79
- const response = await originalFetch(input, init);
80
+ const _token = storage.getItem("jwtToken").replace(/"/g, "");
81
+ console.log("---skip renewal, _token---", _token);
82
+ const _init = {
83
+ ...init,
84
+ headers: {
85
+ ...init.headers,
86
+ Authorization: `Bearer ${_token}`
87
+ }
88
+ };
89
+ console.log("---skip renewal, init---", JSON.stringify(_init));
90
+ const response = await originalFetch(input, _init);
80
91
  console.log("---response--", JSON.stringify(response));
81
92
  console.log("---response, json--", await response.json());
82
93
  return response;
@@ -69,13 +69,24 @@ const originalFetch = window.fetch;
69
69
  const fetchInterceptor = (storage) => {
70
70
  window.fetch = async (input, init = {}) => {
71
71
  console.log("---input---", JSON.stringify(input));
72
+ console.log("---init---", JSON.stringify(init));
72
73
  const url = input instanceof Request ? input.url : input;
73
74
  console.log("---url---", url);
74
75
  const byPass = init.headers ? await init.headers.get("x-by-pass") : false;
75
76
  if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
76
77
  console.log("---skip renewal---");
77
78
  try {
78
- const response = await originalFetch(input, init);
79
+ const _token = storage.getItem("jwtToken").replace(/"/g, "");
80
+ console.log("---skip renewal, _token---", _token);
81
+ const _init = {
82
+ ...init,
83
+ headers: {
84
+ ...init.headers,
85
+ Authorization: `Bearer ${_token}`
86
+ }
87
+ };
88
+ console.log("---skip renewal, init---", JSON.stringify(_init));
89
+ const response = await originalFetch(input, _init);
79
90
  console.log("---response--", JSON.stringify(response));
80
91
  console.log("---response, json--", await response.json());
81
92
  return response;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.35",
2
+ "version": "1.2.37",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {