base_ui/server/readme.md

34 lines
877 B
Markdown
Raw Normal View History

2025-02-01 09:34:55 +00:00
## The server/ folder is ideal for handling server-side logic, such as:
Database operations
Authentication and authorization
File uploads and processing
Integration with third-party APIs
7. Accessing Environment Variables
You can access environment variables in your server-side code using process.env or Nuxt 3s runtime config.
Example:
ts
Copy
export default defineEventHandler((event) => {
const apiKey = process.env.API_KEY;
return { apiKey };
});
8. Server-Side Rendering (SSR) Support
The server/ folder works seamlessly with Nuxt 3s SSR capabilities. For example, you can fetch data from your API routes during SSR using useFetch or useAsyncData.
Example:
vue
Copy
<!-- <script setup>
const { data } = await useFetch('/api/hello');
</script>
<template>
<div>
<h1>{{ data.message }}</h1>
</div>
</template> -->