I'm saving my API credentials in the privateRuntimeConfig
option of the nuxt.config.js
file. I want these keys secure in server, I don't want these in client.
Now, I want to send a request to the API after the user click a button, but I need to use that keys, but they are not in client. So, I don't know how to do it. I have something like this:
index.vue
<template>
<form method="post" action="#" @submit.prevent="sendRequest">
<input v-model="someUserData">
<button type="submit">Send some data :D</button>
</form>
</template>
<script>
...
data() {
return() {
someUserData: ""
}
},
methods: {
sendRequest() {
// Here I should send the request using the API Keys
}
}
...
</script>
My main idea was that when the user click the button, a request must be sent to the Nuxt server with the user data introduced in the form, so, in the Nuxt server I can access to the API credentials and then send the request to the API... but sincerely I don't know how to access to the Nuxt server, I don't know if I can create routes inside the Nuxt server to send request form the Nuxt client
Can you help me?