Retrieving data without using getServerSideProps and not exposing API keys
In my application I have a custom _app file which restricts using getServerSideProps but I need to retrive data from and external API without exposing keys, what is the best possible way to go about it?
12 Replies
use an api route
So this would be 2 calls to external source and my own server from frontend?
client -> next api -> external api -> next api (response) -> client (response)
plus you can add caching and stuff
Thank you!
^^
Why not call external api on ssr or ssg straight
What kind of caching?
you can use something with redis to a more "vendor free" example
or cache headers
youtube.com/@bholmesdev (@BHolmesDev)
With serverless on the rise, cache is king 💰
To speed up responses and cut down on your server biil, let's walk through Cache-Control headers that'll fine-tune how and where cache is stored!
#WhiteboardTheWeb edition 59
Likes
1063
Retweets
145
Twitter
Arent those disabled when using custom app file?
Oh didnt know you use that
No problem haha, not using next13 yet :d