aboutsummaryrefslogtreecommitdiff
path: root/src/other/EmulatorPage.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/other/EmulatorPage.jsx')
-rw-r--r--src/other/EmulatorPage.jsx29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/other/EmulatorPage.jsx b/src/other/EmulatorPage.jsx
index 9adc129f..371bac7c 100644
--- a/src/other/EmulatorPage.jsx
+++ b/src/other/EmulatorPage.jsx
@@ -69,15 +69,26 @@ const EmulatorPage = () => {
const handleClick = useCatch(async (latitude, longitude) => {
if (deviceId) {
- const params = new URLSearchParams();
- params.append('id', devices[deviceId].uniqueId);
- params.append('lat', latitude);
- params.append('lon', longitude);
-
- const response = await fetch(`http://${window.location.hostname}:5055?${params.toString()}`, {
- method: 'GET',
- mode: 'no-cors',
- });
+ let response;
+ if (window.location.protocol === 'https:') {
+ const formData = new FormData();
+ formData.append('id', devices[deviceId].uniqueId);
+ formData.append('lat', latitude);
+ formData.append('lon', longitude);
+ response = await fetch(window.location.origin, {
+ method: 'POST',
+ body: formData,
+ });
+ } else {
+ const params = new URLSearchParams();
+ params.append('id', devices[deviceId].uniqueId);
+ params.append('lat', latitude);
+ params.append('lon', longitude);
+ response = await fetch(`http://${window.location.hostname}:5055?${params.toString()}`, {
+ method: 'POST',
+ mode: 'no-cors',
+ });
+ }
if (!response.ok) {
throw Error(await response.text());
}