-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get my secret value in a fetch method ? #21
Comments
Fetch will be executed on client side too when navigating between pages, so using secret wont work like this |
Humm here is the doc : https://fr.nuxtjs.org/api/pages-fetch/ Extract from doc :
So normaly, the first time, I will be able to catch the secret env on the server side ? |
up ! Same probleme with asyncdata method... |
Your fetch should not rely on a secret. If it does, you should make a small API endpoint in the nuxt server.js. This backend has access to the secret without it ever getting into the frontend. You can then call that endpoint from your fetch to get the data. Anything to do with sensitive keys should always be handled in the backend which the frontend can talk to through an API endpoint. |
Thanks @Soviut, I would say the same. It does seem strange to me that you would want the API call to happen if you access the page from the server but not happen if you access the page from the client, but I don't know your specific use case so won't comment further. @bat79a In your first example you have destructured I can't see any reason why |
Hi.
I'm trying to catch my secret value in a fetch method, can you tell me how to do that ?
Env vars works well but the secret env doesn't work.
I have tryed this in my index.vue :
Here is my nuxt.config.js :
Thx a lot.
The text was updated successfully, but these errors were encountered: