I am building a React/Node.js web app that frequently uses the Spotify API (for searches, getting user data etc.) I am wondering if I should make requests to the Spotify API directly from the front-end, or make calls to my own backend which would then handle the Spotify API requests.
My thoughts:
Calling external API from front-end:
- Potentially slower experience for user as front-end has more code (for example making 3 Spotify API requests inside of a useEffect hook).
- Potential security concerns? Spotify API requires an access_token header on all requests.
Calling external API from back-end:
- Also potentially slower experience for user because of extra round trip to backend.
- Unnecessary requests to my own back-end (higher costs, cloud bill etc.).
Any advice here is appreciated.
access_token
part and that one must happen in the backend, end of "discussion". – Gomuti