How to hide api key in javascript?

Whatdoman

To apply the ChatGPT API to my web service, I called chatgpt using chatgptapi in Javascript. When I looked at the browser developer tool, my chatgpt apikey was exposed. I want to hide the apikey. Please let me know.

I connected the apikey javascript file to index.html and created the apikey javascript file when deploying to the Netlify Built command, but this only allowed me to hide the api key on Github and not in my service.

alex067

You can't hide an API key from the browser. It's just not possible.

It sounds like you're calling the API directly from your frontend app, which is exposing your key via simply inspecting the network tab.

There's many different solutions to this, the most straight forward being having your frontend make a request to your backend, and your backend deals with communicating with ChatGPT.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related