@econneq/gql-auth 1.2.4 → 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.
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -19
- package/package.json +1 -1
package/dist/client.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
@@ -7,37 +7,35 @@ export default async function getApolloClient(options, domain, config) {
|
|
|
7
7
|
const isServer = typeof window === "undefined";
|
|
8
8
|
const { Subdomains } = config;
|
|
9
9
|
const apiKey = process.env.API_KEY || "";
|
|
10
|
-
const protocol = process.env.NEXT_PUBLIC_PROTOCOL || process.env.PROTOCOL;
|
|
11
|
-
const hostInt = process.env.NEXT_PUBLIC_INTERNAL_API_URL || process.env.INTERNAL_API_URL; // e.g api:8000 (docker) or 127.0.0.1:8100 (VPS host) or localhost:8001 (local host)
|
|
12
10
|
const urlDomain = process.env.NEXT_PUBLIC_DOMAIN_URL || process.env.DOMAIN_URL; // e.g e-conneq.com
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!hostInt)
|
|
17
|
-
throw new Error("Env (INTERNAL_API_URL) is required");
|
|
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_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
|
|
18
14
|
if (!urlDomain)
|
|
19
15
|
throw new Error("Env (DOMAIN_URL) is required");
|
|
20
|
-
if (!
|
|
21
|
-
throw new Error("Env (
|
|
16
|
+
if (!protocol)
|
|
17
|
+
throw new Error("Env (PROTOCOL) is required");
|
|
18
|
+
if (!urlBackEndInt)
|
|
19
|
+
throw new Error("Env (BACKEND_URL_INT) is required");
|
|
20
|
+
if (!urlBackEndExt)
|
|
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
|
|
26
|
+
let destUrl;
|
|
27
27
|
const sourceHost = `${protocol}${tenant?.subdomain || "public"}.${urlDomain}`;
|
|
28
28
|
if (isServer) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
uri = `${baseUrl}/graphql/`;
|
|
29
|
+
destUrl = `http://${urlBackEndInt}`;
|
|
30
|
+
uri = `${destUrl}/graphql/`;
|
|
32
31
|
}
|
|
33
32
|
else {
|
|
34
33
|
uri = "/api/graphql";
|
|
35
|
-
|
|
36
|
-
baseUrl = `${urlBackEnd}`;
|
|
34
|
+
destUrl = `${protocol}${urlBackEndExt}`;
|
|
37
35
|
}
|
|
38
|
-
console.log("uri", uri);
|
|
39
|
-
console.log("
|
|
40
|
-
console.log("
|
|
36
|
+
console.log("g-auth uri ==============", uri);
|
|
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':
|
|
50
|
+
'Referer': destUrl,
|
|
53
51
|
'Host': isServer ? sourceHost : window.location.host,
|
|
54
52
|
};
|
|
55
53
|
return new ApolloClient({
|