Google Custom Search Api in Glitch

Hello,

I am in one of the projects of FreeCodeCamp (Image Search Abstraction Layer) and I need to create a search engine in my web, in Glitch.
I am using the default code for new Projects:

  • assets
  • env
  • package.json
  • public/client.js
    -public/style.css
  • README.md
  • server.js
  • views/index.html

I already created one search engine in google through the google custom search API and I have three details in the panel that controls that:

  • Search engine ID
  • Public URL
  • Get code

My question is where should I place the details of my customized search engine?

I placed the code in the html but it doesn’t work
Do I need to place the values of Search Engine ID and the Public URL in the file .env. ?
If that how should I name the constants where those values are assigned to?

I have already found the answer:

  • Code in HTML
  • Values of Search engine ID and Public URL in .env file with the name of the constants exactly as there are in the control panel of the google customized search engine API.

An the most important: in the dropdown menu of sites to search we need to set it to “Search the entire web but emphasized included sites”

1 Like

Glad you found the answer! The .env file is a good place to store any sensitive details, like API keys and passwords that your apps use. That way, they aren’t shared publicly in your code because you just refer to the values instead.