@opexa/portal-components 0.0.836 → 0.0.837
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,3 +1,4 @@
|
|
|
1
|
+
import { Capacitor } from '@capacitor/core';
|
|
1
2
|
import { ENVIRONMENT, PLATFORM_CODE, PLATFORM_ID, SITE_ID } from '../constants/index.js';
|
|
2
3
|
export async function graphqlRequest(url, query, variables, options) {
|
|
3
4
|
const headers = new Headers();
|
|
@@ -11,6 +12,21 @@ export async function graphqlRequest(url, query, variables, options) {
|
|
|
11
12
|
new Headers(options?.headers).forEach((value, key) => {
|
|
12
13
|
headers.set(key, value);
|
|
13
14
|
});
|
|
15
|
+
const domain = typeof window === 'undefined'
|
|
16
|
+
? null
|
|
17
|
+
: !Capacitor.isNativePlatform()
|
|
18
|
+
? null
|
|
19
|
+
: Capacitor.getPlatform() === 'ios'
|
|
20
|
+
? `ios/${PLATFORM_CODE}`.toLowerCase()
|
|
21
|
+
: Capacitor.getPlatform() === 'android'
|
|
22
|
+
? `android/${PLATFORM_CODE}`.toLowerCase()
|
|
23
|
+
: null;
|
|
24
|
+
if (domain) {
|
|
25
|
+
headers.set('Domain', domain);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
headers.delete('Domain');
|
|
29
|
+
}
|
|
14
30
|
const info = getOperationInfo(query);
|
|
15
31
|
const url_ = new URL(url);
|
|
16
32
|
if (info) {
|
|
@@ -109,6 +125,21 @@ export async function graphqlUpload(url, query, variables, options) {
|
|
|
109
125
|
headers.set('Platform-Code', PLATFORM_CODE);
|
|
110
126
|
headers.set('Environment', ENVIRONMENT);
|
|
111
127
|
headers.delete('Content-Type');
|
|
128
|
+
const domain = typeof window === 'undefined'
|
|
129
|
+
? null
|
|
130
|
+
: !Capacitor.isNativePlatform()
|
|
131
|
+
? null
|
|
132
|
+
: Capacitor.getPlatform() === 'ios'
|
|
133
|
+
? `ios/${PLATFORM_CODE}`.toLowerCase()
|
|
134
|
+
: Capacitor.getPlatform() === 'android'
|
|
135
|
+
? `android/${PLATFORM_CODE}`.toLowerCase()
|
|
136
|
+
: null;
|
|
137
|
+
if (domain) {
|
|
138
|
+
headers.set('Domain', domain);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
headers.delete('Domain');
|
|
142
|
+
}
|
|
112
143
|
const body = createUploadBody(query, variables);
|
|
113
144
|
const info = getOperationInfo(query);
|
|
114
145
|
const url_ = new URL(url);
|
|
@@ -60,6 +60,22 @@ httpRequest.json = async (url, opts = {}) => {
|
|
|
60
60
|
new Headers(opts.headers).forEach((value, key) => {
|
|
61
61
|
headers.set(key, value);
|
|
62
62
|
});
|
|
63
|
+
/* 👌🏻 Override domain set outside */
|
|
64
|
+
const domain = typeof window === 'undefined'
|
|
65
|
+
? null
|
|
66
|
+
: !Capacitor.isNativePlatform()
|
|
67
|
+
? null
|
|
68
|
+
: Capacitor.getPlatform() === 'ios'
|
|
69
|
+
? `ios/${PLATFORM_CODE}`.toLowerCase()
|
|
70
|
+
: Capacitor.getPlatform() === 'android'
|
|
71
|
+
? `android/${PLATFORM_CODE}`.toLowerCase()
|
|
72
|
+
: null;
|
|
73
|
+
if (domain) {
|
|
74
|
+
headers.set('Domain', domain);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
headers.delete('Domain');
|
|
78
|
+
}
|
|
63
79
|
const response = await fetch(url, {
|
|
64
80
|
...opts,
|
|
65
81
|
headers,
|