N
Nuxt7mo 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
Smef7mo 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
PhillipOP7mo ago
got it! You mean the server/utils directory, right? I will just go with that. Thank you
Smef
Smef7mo 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