Accessing Hf secrets in a Docker React app in Spaces

Hi, I have been trying to connect two spaces, One a react frontend and another a FastAPI backend. The backend is private and to access it through the frontend it requires the access token to be given with each request. When I tried adding the HF access token as a secret in the frontend space and trying to use import.meta.env Isn’t working.

When I tested by giving the token directly in the UI just for testing purpose, The calls are getting through correctly. What could be the issue. I’m new to React and web dev in general. Appreciate any help.

1 Like

trying to use import.meta.env

This would allow reading environment variables within a React app running in the browser, but nothing should be stored there.

I tested by giving the token directly in the UI just for testing purpose

Passing the token each time is cumbersome but relatively reliable.