Skip to content

Retrieving API keys on the frontend of NextJS app in production #12531

Discussion options

You must be logged in to vote

You shouldn't make protected API calls in the client-side: no matter what you do, the private key will always be exposed.

My suggestion is to use API Routes to create your own API route and make the request to the protected API inside it, this way you can safely use your private key without exposing it to the client

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@taylor-lindores-reeves
Comment options

@willemliu
Comment options

Comment options

You must be logged in to vote
8 replies
@taylor-lindores-reeves
Comment options

@rafaelalmeidatk
Comment options

@taylor-lindores-reeves
Comment options

@willemliu
Comment options

@willemliu
Comment options

Answer selected by taylor-lindores-reeves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants