Make it possible to expose routes as an API endpoint
// routes/web.php
Route::group(['prefix' => 'whatever-i-want'], function () {
Ziggy::route();
});
Then the client could get that and cache it for a short time in local storage.
Pros: Get it once, it's clean and separated, you can put it behind auth and middleware, not janking up your templates with a blade directive Cons: Extra HTTP request, caching means it can get out of sync
I like it. I'd want to think through what the client side would look like a little.
I personally love this addition, I currently work with Quasar alot which prevents me from using a blade directive.
@hawkleaf would it be useful to you if we provided the route() helper as a dynamically compiled JS file as well? If so, would you rather have both together, or separate endpoints for route json and the helper JS?
Might be overthinking this but it could be pretty cool.
I don't think it'd hurt to implement both. I think though that if someone were to use that route they'd already have access to the helper JS though. Then again, I might not be the right person to ask as my experience with this type of communication between apps is very limited.
+1 for
separate endpoints
so you can use the global helper for whatever & the route for the little secrets you want to keep away but i think this will make more sense if we have a whitelist / blacklist to what show up at which end point.
I'm going to close this issue. I would accept a PR for it, but it's not super related to current roadmap.