---
title: "Discussion on \"Hide API Keys using Netlify token-hider Function\" | Hashnode"
description: "Discussion on \"Hide API Keys using Netlify token-hider Function\". So, you are making a Frontend application which interacts with a third-party API and chances are high that you will be using an API Key. But, how do you protect your API Key from being exposed to others?\nSadly, you can't hide your API key in the Fron..."
url: "https://hashnode.com/posts/hide-api-keys-using-netlify-token-hider-function/5f809db97762251b305d8879"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Hide API Keys using Netlify token-hider Function](https://aadhi.hashnode.dev/hide-api-keys-using-netlify-token-hider-function?utm_source=hashnode&utm_medium=feed)

So, you are making a Frontend application which interacts with a third-party API and chances are high that you will be using an API Key. But, how do you protect your API Key from being exposed to others? Sadly, you can't hide your API key in the Fron...

Oct 9, 2020 · 3 min read · aadhi.hashnode.dev  
Updated Oct 12, 2020  
Read the article

-   [#netlify](https://hashnode.com/tag/netlify)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#apis](https://hashnode.com/tag/apis)
-   [#api](https://hashnode.com/tag/api)

## Written by

[Aadhi Keerthanan](https://hashnode.com/@DevAadhi)

@DevAadhi · Coimbatore, Tamilnadu, India

  
[View profile](https://hashnode.com/@DevAadhi)

Web Developer

## Responses 2

Markdown supported · ⌘↵ to post

[Dumi](https://hashnode.com/@dumidummy)

[Mar 8, 2021](https://hashnode.com/posts/hide-api-keys-using-netlify-token-hider-function/5f809db97762251b305d8879/comment/60463d0a73cc1742999bfaf0)

Hello, I found your article very useful. But, what if the API use the key in headers, not parameters? This is the example how I get data from the API:

```
const BASE_URL = ".....";
const ENDPOINTS = "/type=movie"; // There is more than one endpoint, it's dynamic
const API_KEY = {
  headers: {
    "key": "value";
  }
};

axios.get(`${BASE_URL}${ENDPOINTS}`, API_KEY).then(........
```

[Aadhi Keerthanan](https://hashnode.com/@DevAadhi)

[Mar 9, 2021](https://hashnode.com/posts/hide-api-keys-using-netlify-token-hider-function/5f809db97762251b305d8879/comment/60463d0a73cc1742999bfaf0#reply-604760feefdd714f7023997a)

Hi, you are directly fetching the api from your js file instead you have to send a request to the token-hider.js like this const res = await fetch("/.netlify/functions/token-hider" + "?q=" + searchField.value). I have used the fetch api but you can use axios if you prefer it. Can you send the token-hider.js file so that I can take a look and see what's the problem.

[Dumi](https://hashnode.com/@dumidummy)

[Mar 10, 2021](https://hashnode.com/posts/hide-api-keys-using-netlify-token-hider-function/5f809db97762251b305d8879/comment/60463d0a73cc1742999bfaf0#reply-604810b2c64c63545921cb95)

Thanks for your response, but the code above is code before I implemented it in token-hider.js (my current code). I don't know how to change it in token-hider.js. Your tutorial (and all the tutorials I read on Google) uses an API that puts the key in a parameters, while the API I use is in the headers. [Aadhi Keerthanan](https://hashnode.com/@DevAadhi)

[Aadhi Keerthanan](https://hashnode.com/@DevAadhi)

[Oct 9, 2020](https://hashnode.com/posts/hide-api-keys-using-netlify-token-hider-function/5f809db97762251b305d8879/comment/5f809df57762251b305d8880)

Hope everyone enjoys the article.
