mirror of
https://github.com/traccar/traccar-web.git
synced 2025-01-09 04:37:33 +08:00
Fix HTTPS emulator (fix #5337)
This commit is contained in:
parent
57598cef5e
commit
8ab0fc98d7
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user