0

Our former developers created this code below. However, when it renders on our site, it displays the API key. Is there a better way to hide the API key while still enlisting the script to be executed?

wp_enqueue_script('hw-google-map','https://maps.google.com/maps/api/js?v=3&key=APIKEYTHATISPUBLIC', array('jquery'), 1.1, false);
1
  • 1
    This is the correct way of sending a request to the Google Maps API. Any security restrictions would be applied within the Google account itself.
    – vancoder
    Commented Mar 6, 2023 at 16:44

1 Answer 1

0

While you can't obfuscate/hide the code, you can restrict access by domain: https://developers.google.com/maps/api-security-best-practices

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.