Fetch from external API, Client or Server?
If I want to fetch from an external API (in my case, Spotify's api), should I do it from the client using tanstack query or make a trcp api that fetches it from there and then use my trpc api in the client? (using t3)
4 Replies
if you have some kind of secret
the server (backend) is the better place to call
otherwise the secret will be in the client bundle
I need the access token, so it would need to be sent to the client yeah
Should i just do it from the server to avoid the client getting it to avoid malicious code stealing it?
if you have a unique acess token for the access, the server is 100% where you would call the spotify api
if its based on the client oauth token, then you can do either way
Yeah its the user token, hmm okay, thanks