Proper localhost HTTP Referer for Google Maps API using Cordova 11

555 Views Asked by At

Cordova 11 introduced a new default scheme for running web apps on Android devices. In earlier releases, apps were loaded using the file: scheme. The new default scheme is to load apps from https://localhost.

Our app uses Google Maps which can whitelist HTTP REFERRERs that connect to the service. The change in Cordova default scheme affects the whitelist entry. Adding https://localhost to the whitelist does not work, as well as several variations. What is the proper whitelist entry for apps that run on Cordova 11?

Here are the localhost entries at Google that do not work for Cordova 11...

enter image description here

Adding the following preference to config.xml did NOT work...

<preference name="hostname" value="localhost" />

However, the following does allow the file: scheme to continue to work...

<preference name="AndroidInsecureFileModeEnabled" value="true" />

Has anyone successfully whitelisted a Cordova 11 webapp running on Android from localhost? If so, what whitelist entry enables localhost? All of the above entries result in...

"Google Maps JavaScript API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error Your site URL to be authorized: https://localhost/index.html", source: https://localhost/js/src/main/Main.js

Using Android Studio BumbleBee 2021.1.1 Patch 2 to run webapp.

0

There are 0 best solutions below