Is there any way to access secrets from a static html space (javascript)?
Hello,I have a Huggingface static space that uses javascript. I know that space secrets are accessible as environment variables. Is there any way to access these secrets from javascript?Thanks
2023-03-15T17:53:48Z
Hi@Giustiniano,Do you need the secrets at build time? If not, please note that you cannot store secrets in a static web page. This is because the requests and code on the page are public, allowing anyone to inspect the code and access the secret. To keep your secret secure, you may need to use a backend proxy.
2023-03-15T17:57:15Z
In my case, there’s nobuild time, it’s a static page with vanilla JS. I was wondering if there was a way to access the environment variables from javascript, maybe with a huggingface spaces api
2023-03-15T18:21:10Z
You can set secrets via API, but I don’t think you can retrieve it unless you’re inside a Gradio/Streamlit/Docker SDK. Since if you use a Secret on a static page, it won’t be secret anymore.