CMS Development

Mohesh_Borah
Participant

Unable to retrieve the environment variable in the module.html - Google Map Key

Hi All,

 

Hope you all are doing great...!!!

 

I am unable to retrieve the value of - an environment variable in HUBL(module.html).

 

Functional requirement is to embed the google map into a page.

 

I am getting the location info from the -HubDb table(column type-location).

 

And while appending the 'Google-API-Key' in the <iframe>, getting the required output.

 

But the problem is with the security, as the -key will be available to the end-user in the website page.

 

So how to get the value of a environment variable inside module.html ?

 

Present Embed URL Structure- <iframe width="600 px" height="450 px" frameborder="0" scrolling="no" src="https://www.google.com/maps/embed/v1/place?key={{ module.google_map_api_key }}&q={{dynamic_page_hubdb_row.location["lat"]}},{{dynamic_page_hubdb_row.location["lon"]}}" allowfullscreen></iframe>

 

Thanks & Regards,

Mohesh Borah

0 Upvotes
2 Replies 2
natsumimori
Community Manager
Community Manager

Unable to retrieve the environment variable in the module.html - Google Map Key

Hi @Mohesh_Borah ,

 

Thank you for reaching out to the HubSpot Community.

@Kevin-C and @John , would you mind sharing your advice for @Mohesh_Borah ?

Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

Unable to retrieve the environment variable in the module.html - Google Map Key

Hey @Mohesh_Borah and thank you @natsumimori 

 

Your API key WILL be available to the end user in the page's Html due to how the iframe calls the API.

 

As a best practice you should restrict access to your API to only the page's URL restricting access to the API key via the Credentials Panel

 

 

Kevin Cornett - Sr. Solutions Architect @ BridgeRev