---
title: "Discussion on \"How to hide your front-end API keys\" | Hashnode"
description: "Discussion on \"How to hide your front-end API keys\". Most of web API services require the use of an API key or an access token to get authorization. The problem with this setup is that when you include your credentials with your front-end code, any user who understands the basics of HTTP and knows how ..."
url: "https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e"
---

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

Discussion

# [How to hide your front-end API keys](https://blog.mauriciorobayo.com/how-to-hide-your-front-end-api-keys?utm_source=hashnode&utm_medium=feed)

Most of web API services require the use of an API key or an access token to get authorization. The problem with this setup is that when you include your credentials with your front-end code, any user who understands the basics of HTTP and knows how ...

Feb 12, 2020 · 8 min read · blog.mauriciorobayo.com  
Updated Oct 28, 2021  
Read the article

-   [#proxy](https://hashnode.com/tag/proxy)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)
-   [#frontend](https://hashnode.com/tag/frontend)
-   [#apis](https://hashnode.com/tag/apis)
-   [#security](https://hashnode.com/tag/security)

## Written by

[Mauricio Robayo](https://hashnode.com/@mauriciorobayo)

@mauriciorobayo

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

Full-Stack JavaScript Developer

Building for the web is my passion. Constantly learning and getting better.

## Responses 6

Markdown supported · ⌘↵ to post

[Ngwube Precious](https://hashnode.com/@Prewsh)

[Nov 28, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5fc2438555b779631e1acdf4)

nice article, really helped me, but I couldn't host the proxy server on heroku, keeps throwing this error

`src/config.ts(27,7): error TS2322: Type '{ route: string; allowedMethods: string[]; target: string; headers: { Accept: string; Authorization: string; }; body: string; }' is not assignable to type 'Proxy'`

I don't know if anybody, has the same error and I am also trying to work on Github graphql API, that's why I added `body`

[Nora Brown](https://hashnode.com/@norabrowndesign)

[Mar 28, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e7fbbeeba34afe713b7c324)

This article was quite helpful. I had to make a change to `api-key-proxy-server` to get it to work. Please see [this Github issue](https://github.com/MauricioRobayo/api-key-proxy-server/issues/31#issue-589658801) .

[Mauricio Robayo](https://hashnode.com/@mauriciorobayo)

[Mar 29, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e7fbbeeba34afe713b7c324#reply-5e800b8bcceb43e213bf6b8a)

Thanks for taking the time to report the issue! Fixed.

[Gafar Popoola](https://hashnode.com/@gafarp)

[Feb 16, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e48f6958c89a92316cd39e9)

Great article. This solution only partly addresses the problem from the browser's point of view. The proxy server can still be tricked by spoofing the origin header using a tool like curl. There's really no way your proxy server would differentiate a spoofed request from a request that originated from the browser.

[Mauricio Robayo](https://hashnode.com/@mauriciorobayo)

[Feb 18, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e48f6958c89a92316cd39e9#reply-5e4c0b61205a551d167e7524)

You are 100% right: This only addresses the problem from the browser's point of view. Thanks for the feedback and for bringing up the issue.

[Pankaj C.](https://hashnode.com/@pkj)

[Feb 22, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e48f6958c89a92316cd39e9#reply-5e51a879205a551d167ed7e6)

What can be a solution for this problem?

[Zlati Pehlivanov](https://hashnode.com/@zlatip)

[Feb 15, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e47f6368c89a92316cd2e15)

That all sounds right, for web at least, but most of the services that require api key, actually require from you to enter a domain to which this api key is given and for mobiles sha1 of your app at least on android. So requests from different domain and from different mobile app will fail. How this proxy makes things better, what about you will have to pay more for that proxy to work non stop for everybody. Why implementing the same authorization twice?

[Mauricio Robayo](https://hashnode.com/@mauriciorobayo)

[Feb 16, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e47f6368c89a92316cd2e15#reply-5e48a97a8c89a92316cd363d)

Hi, you are right! That's not the use case for what's described. I don't see why would you implement a proxy server if the API service you are using handles credentials authorization with allowed domains. That's stated on the article.

[Micah Lindley](https://hashnode.com/@micahlt)

[Feb 14, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e46fb068c89a92316cd1d44)

This article is a godsend! I’ve been struggling with this and actually just published an [article](https://blog.micahlindley.com/im-doing-everything-wrong-ck6mhrfla01u0d9s1dwuj3mtg) detailing that I’m going to have to rebuild all of my web apps because of security issues. But now I don’t! Can’t thank you enough- thanks for the great article!

[George Benjamin](https://hashnode.com/@georgeben)

[Feb 14, 2020](https://hashnode.com/posts/how-to-hide-your-front-end-api-keys/5e445ab98c89a92316ccdc6e/comment/5e4670ff205a551d167e0c47)

Great article!
