Geolocation fails on Chromium for Wix sites

Question:
How to create a workaround for geolocation in Chromium 126 and later based browsers?

Product:
wixWindow.getCurrentGeolocation() fails with the following error in browsers based on Chromium 126 or later like Chrome, Edge, Opera, etc.:

comlink.ts:343 Uncaught (in promise) DOMException: Failed to execute ‘postMessage’ on ‘MessagePort’: function toJSON() { [native code] } could not be cloned.
at https://static.parastorage.com/services/wix-thunderbolt/dist/thunderbolt-commons.14431d95.bundle.min.js:1:18777

What are you trying to achieve:
The getCurrentGeolocation() uses the browser’s native geolocation capability to return user’s location coordinates. But the (Chrome Platform Status) change in Chromium 126 breaks the wix-thunderbolt library. It has been 2 weeks since Wix sites are unable to get geolocation but no fix is available from the Velo team.

What have you already tried:
Since Wix sites do not allow permissions policy for allowing geolocation on iframes, it is not possible to implement a native JS geolocation finding without using wixWindow. And wixWindow / wix-thunderbolt library is broken. So need another workaround.

Additional information:
Very easy to reproduce the issue with this code:
import wixWindow from ‘wix-window’;

async function getLocation() {

return await wixWindow.getCurrentGeolocation()
.then( (obj) => {
	let locationLatitude = obj.coords.latitude;
	let locationLongitude = obj.coords.longitude;
	console.log('locationLatitude ' + locationLatitude)
	console.log('locationLongitude ' + locationLongitude)
} )
.catch( (error) => {
	console.log('error ' + error.message)
});

}

$w.onReady(function () {
getLocation()

});

Workaround Options (Since a permanent fix isn’t available yet):

  1. Contact Wix Support:
  • The most reliable solution is to wait for Wix to address the issue. Contact Wix support and explain the problem you’re facing. They might have an estimated timeline for a fix or offer alternative solutions.
  1. Explore Third-Party Services (Limited):
  • Some third-party services offer geolocation APIs that might work within Wix’s iframe limitations. However, be cautious:
    • Research the service’s reliability and privacy practices.
    • Ensure it integrates seamlessly with your Wix site.
    • This approach might require additional coding and might not be a perfect solution.

Current Limitations:

Unfortunately, due to Wix’s iframe restrictions, there’s no simple workaround using pure JavaScript. The options above are your best bets until a permanent fix arrives.

Additional Tips:

  • Stay updated on the Wix Velo development blog or community forums for any updates regarding the wixWindow.getCurrentGeolocation() issue.
  • Consider alternative functionalities that might achieve your desired outcome without relying on geolocation.