What is @routes in app.blade.php [inertia-react app]?
I can see @routes directive in app.blade.php in my inertia-react app. It make list of all routes and their methods. So it it really necessary to use them? And why they are necessary?
@vincent15000 Its not same but related. First I was bit confuse with @routes in my app.blade.php. And when I get the idea that it shows all named routes in source code, I wanted to make sure I can exclude some of them for security reason. And fortunately Ziggy allows this.
@sannjay I also had a discussion here in another post in concern with security reason.
If you are using InertiaJS, you can use only the Laravel routes, so there's really no problem.
If you don't user InertiaJS but pure VueJS for example, you have to worry about what you are doing. If your API routes are correctly secured, the only problem is you have to choose if you want to expose all routes to the users or not. If not, the only way I have found is to make a RouteController accessible via the API to send the menu /routes accessible by the connected user according to his permissions.
@sannjay But sure too that @routes retrieves all routes, even those not needed (I mean if a user isn't allowed to access some routes). But if your routes correctly secured on the backend side, there is no problem.
I begin to understand that it's an existing and permanent problem when working with a JS framework for the frontend when you have a separate backend.
@Sinnbeck Do you mean that ziggy can hide some routes ? I mean ... on the frontend JS side, if you write some routes, they are all in the script, aren't they ?
@vincent15000 it shows all in js by default, but you can ask it to hide certain routes, for instance horizon, debugbar or some other route you don't use with inertia
@Sinnbeck Ok sorry that's not clear for me ... it shows all routes by default, but I can hide certain routes ... are they really hidden ? If I read the script, I will not be able to find the hidden routes ?
@Sinnbeck That's very interesting ;) ... I already had a discussion on Laracast around security with SPA app.
If I want to filter my routes and for example hide certain routes if a user is not an admin, do I necessarily need some flag (for example ``ìsAdmin```) stored in vuex store or in the sessionStorage for example ? Or is it possible to do another way ?
@Sinnbeck My reformulate my question : is it possible to use it via an API with back and front in two separate environments ?
But I think I have already the answer ... If back and front are separate, the only way to send the routes to the front is via an API call ... would ziggy be useful in such a situation ?