N
Nuxt3w ago
Phillip

Private server routes

Hello guys, how can i flag my nuxt 3 api routes as private meaning they can only be accessed from the server itself and is not viewable by the user? Since every API file I put inside /server/api, but also /server/, will be accessible by other users. How can I prevent this?
3 Replies
Smef
Smef3w ago
You could make those features utility functions rather than routes. The purpose of the routes is to be accessible from your front-end to retrieve data, etc. If you wanted to make sure only authorized users can retrieve data you’ll need to implement authorization of some format
Phillip
Phillip3w ago
got it! You mean the server/utils directory, right? I will just go with that. Thank you
Smef
Smef3w ago
Yeah. Those would then be functions you would call from your server or API routes Or whatever else server-side
Want results from more Discord servers?
Add your server
More Posts
in defineWebSocketHandler how to allow authenticated users connecting?what i seen most of the time in upgrade you can stop from connecting lets say if user has cookie. thDoes anyone know if @canplaythrough is still a valid listener to use on a `<video /> ` element?Title! Thanks, and let me know if you have an implementation. I want to play a video only when it isuseFetch with patch method is making GET requests insteadHello, I am trying to make a `patch` request to an endpoint on a different server. When making the rNuxt DevTools: RPC error on executing "installNuxtModule"On windows, tried to install module using Nuxt devtools for the first time, specifically Nuxt Icon. Vitest auto-import functionsIs there a way to correctly auto-import functions from Vitest, like `it` and `expect` while preservi"Sub-Router"Do you know if it's possible to sub-routing? Let me explain: I have my page / -> index.vue /about ->Did anyone able to deploy Nuxt 3 prerender site on AWS-Amplify?The deployment show successful, but when I visit https://main.<hash_string>.amplifyapp.com, I'm not getCookie in server routes returns undefined on initial page serve (ssr)Hi there, Experiencing an issue where cookies are unavailable in H3 events inside `/server/api/` rHow can I pass more props in a nuxtlink or in a router in nuxt 3I need help... I would like to know how can I pass parameters like it was done in Vue 2 when you pasCustom Typescript SettingsHello, I am reading the documentation on the subject of injecting custom Typescript Settings, I can