@econneq/gql-auth 1.2.5 → 1.2.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA2B,MAAM,gBAAgB,CAAC;AAGvE,wBAA8B,eAAe,CAC3C,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,CAAC,EAAE;IACP,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAkE9B"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA2B,MAAM,gBAAgB,CAAC;AAGvE,wBAA8B,eAAe,CAC3C,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACjD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,CAAC,EAAE;IACP,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAgE9B"}
package/dist/client.js CHANGED
@@ -9,35 +9,33 @@ export default async function getApolloClient(options, domain, config) {
9
9
  const apiKey = process.env.API_KEY || "";
10
10
  const urlDomain = process.env.NEXT_PUBLIC_DOMAIN_URL || process.env.DOMAIN_URL; // e.g e-conneq.com
11
11
  const protocol = process.env.NEXT_PUBLIC_PROTOCOL || process.env.PROTOCOL; // e.g https:// or e.g http://
12
- const urlBackEndInt = process.env.NEXT_PUBLIC_BACKEND_INTERNAL_URL || process.env.BACKEND_INTERNAL_URL; // e.g api:8000 (docker) or 127.0.0.1:8100 (VPS host) or localhost:8001 (local host)
13
- const urlBackEndExt = process.env.NEXT_PUBLIC_BACKEND_EXTERNAL_URL || process.env.BACKEND_EXTERNAL_URL; // e.g https://admin.e-conneq.com
12
+ const urlBackEndInt = process.env.NEXT_PUBLIC_BACKEND_URL_INT || process.env.BACKEND_URL_INT; // e.g api:8000 (docker) or 127.0.0.1:8100 (VPS host) or localhost:8001 (local host)
13
+ const urlBackEndExt = process.env.NEXT_PUBLIC_BACKEND_URL_EXT || process.env.BACKEND_URL_EXT; // e.g https://admin.e-conneq.com
14
14
  if (!urlDomain)
15
15
  throw new Error("Env (DOMAIN_URL) is required");
16
16
  if (!protocol)
17
17
  throw new Error("Env (PROTOCOL) is required");
18
18
  if (!urlBackEndInt)
19
- throw new Error("Env (BACKEND_INTERNAL_URL) is required");
19
+ throw new Error("Env (BACKEND_URL_INT) is required");
20
20
  if (!urlBackEndExt)
21
- throw new Error("Env (BACKEND_EXTERNAL_URL) is required");
21
+ throw new Error("Env (BACKEND_URL_EXT) is required");
22
22
  const tenant = domain
23
23
  ? Subdomains.find((s) => s.subdomain.toLowerCase() === domain.toLowerCase())
24
24
  : null;
25
25
  let uri;
26
- let baseUrl;
26
+ let destUrl;
27
27
  const sourceHost = `${protocol}${tenant?.subdomain || "public"}.${urlDomain}`;
28
28
  if (isServer) {
29
- // Use the internal host for the physical connection
30
- baseUrl = `http://${urlBackEndInt}`;
31
- uri = `${baseUrl}/graphql/`;
29
+ destUrl = `http://${urlBackEndInt}`;
30
+ uri = `${destUrl}/graphql/`;
32
31
  }
33
32
  else {
34
33
  uri = "/api/graphql";
35
- // Use the EXTERNAL host for the logical Identity (Host Header)
36
- baseUrl = `${urlBackEndExt}`;
34
+ destUrl = `${protocol}${urlBackEndExt}`;
37
35
  }
38
36
  console.log("g-auth uri ==============", uri);
39
- console.log("g-auth baseUrl ==========", baseUrl);
40
37
  console.log("g-auth sourceHost =======", sourceHost);
38
+ console.log("g-auth destinationHost ==========", destUrl);
41
39
  const csrfToken = options?.csrfToken || (!isServer ? Cookies.get("csrftoken") : "");
42
40
  const headers = {
43
41
  'Content-Type': 'application/json',
@@ -49,7 +47,7 @@ export default async function getApolloClient(options, domain, config) {
49
47
  'X-Process-ID': tenant?.processId || "",
50
48
  'X-Widget-ID': tenant?.widgetID || "",
51
49
  }),
52
- 'Referer': baseUrl,
50
+ 'Referer': destUrl,
53
51
  'Host': isServer ? sourceHost : window.location.host,
54
52
  };
55
53
  return new ApolloClient({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@econneq/gql-auth",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",