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
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
got it! You mean the server/utils directory, right? I will just go with that. Thank you
Yeah. Those would then be functions you would call from your server or API routes
Or whatever else server-side