Hello,
Is it possible to have a completely private API in Nuxt without exposing public server API?
We have a page called example.vue and we want to load data from the server when the client navigates to the page for the first time. All fetching processes should be on the server side, and the private API should not be visible to the clients.
<!-- pages/example.vue -->
<script setup>
// This should be called on the server side
const { data } = await useAsyncData(
"theKey",
() => $fetch("external api"), // This code should not be visible to clients
{
server: true, // Set to true but data won't load on navigation
}
);
</script>
<template>
<div>
<!-- Do something with data on the client side -->
</div>
</template>
we don't want to create server/api/get-data-from-external-api.ts because anyone can hit this endpoint.
Any ideas?