aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-06-10 06:14:01 -0700
committerAnton Tananaev <anton@traccar.org>2024-06-10 06:14:01 -0700
commit8ab0fc98d713102747f5fd376255ee31be69da97 (patch)
treec2210919bc51c561f739ae739a7f17db6a89aa48 /src
parent57598cef5e2f17b498425780858d1cf816c43037 (diff)
downloadtrackermap-web-8ab0fc98d713102747f5fd376255ee31be69da97.tar.gz
trackermap-web-8ab0fc98d713102747f5fd376255ee31be69da97.tar.bz2
trackermap-web-8ab0fc98d713102747f5fd376255ee31be69da97.zip
Fix HTTPS emulator (fix #5337)
Diffstat (limited to 'src')
-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());
}