CMS Development

yhernandez
Participant

How to use environment variables

SOLVE

Hi! I'm doing a get request inside a hubspot form in js module, that request require an authentication token which temporarly I'm using within the function but the best would be have it in a environment variable outside the code and just make the call to that variable and not have it within function. Is possible do that in hubspot? makes sense my question? any similar idea about that best practice would be appriciate..I really would love not have the variable inside the code.

thanks in advance

best

0 Upvotes
1 Accepted solution
Derek_Gervais
Solution
HubSpot Alumni
HubSpot Alumni

How to use environment variables

SOLVE

Hey @yhernandez ,

 

Your question certainly makes sense, but unfortunately it's not possible to configure environment variables in HubSpot in the way you're mentioning.

 

Since the forms module code is running client-side, it's actually not a good idea to include any sensitive authentication details at all. Any access tokens or other authentication details would be exposed in the frontend code and in any AJAX requests being made.

View solution in original post

2 Replies 2
Derek_Gervais
Solution
HubSpot Alumni
HubSpot Alumni

How to use environment variables

SOLVE

Hey @yhernandez ,

 

Your question certainly makes sense, but unfortunately it's not possible to configure environment variables in HubSpot in the way you're mentioning.

 

Since the forms module code is running client-side, it's actually not a good idea to include any sensitive authentication details at all. Any access tokens or other authentication details would be exposed in the frontend code and in any AJAX requests being made.

yhernandez
Participant

How to use environment variables

SOLVE

Thanks for the info @Derek_Gervais and your time. Seems to be I need to move that code into server side. 

Best

0 Upvotes