Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laraguy25's avatar

Inertia.js is displaying all routes using Ziggy in the XHR response

I'm developing an app using Inertia.js with React and am using Ziggy. Whenever a new page is requested via XHR, it returns the props for the page and it also displays all the routes in the ziggy prop. Is there a way to disable this as I don't want to be advertising every route available in my app to the public?

{
    "component": "Profile\/Index",
    "props": {
        "errors": {},
        "auth": {
            "user": {
                "id": 2
            },
        },
        "ziggy": {
            "url": "http:\/\/front.test",
            "port": null,
            "defaults": [],
            "routes": {
                "sanctum.csrf-cookie": {
                    "uri": "sanctum\/csrf-cookie",
                    "methods": [
                        "GET",
                        "HEAD"
                    ]
                },
                "ignition.healthCheck": {
                    "uri": "_ignition\/health-check",
                    "methods": [
                        "GET",
                        "HEAD"
                    ]
                },
                "ignition.executeSolution": {
                    "uri": "_ignition\/execute-solution",
                    "methods": [
                        "POST"
                    ]
                },
                "ignition.updateConfig": {
                    "uri": "_ignition\/update-config",
                    "methods": [
                        "POST"
                    ]
                },
                "site.home": {
                    "uri": "\/",
                    "methods": [
                        "GET",
                        "HEAD"
                    ]
                },
         
0 likes
1 reply
LaryAI's avatar
Level 58

To disable the display of all routes in the Ziggy prop, you can modify the app/Providers/RouteServiceProvider.php file. In the boot method, remove the ->name('api.') from the Route::prefix('api') line. This will prevent the routes from being included in the XHR response.

public function boot()
{
    Route::bind('product', function ($value) {
        return Product::where('slug', $value)->firstOrFail();
    });

    Route::bind('category', function ($value) {
        return Category::where('slug', $value)->firstOrFail();
    });

    Route::bind('user', function ($value) {
        return User::where('username', $value)->firstOrFail();
    });

    Route::bind('order', function ($value) {
        return Order::where('number', $value)->firstOrFail();
    });

    Route::bind('coupon', function ($value) {
        return Coupon::where('code', $value)->firstOrFail();
    });

    Route::bind('address', function ($value) {
        return Address::where('id', $value)->firstOrFail();
    });

    Route::bind('country', function ($value) {
        return Country::where('code', $value)->firstOrFail();
    });

    Route::bind('state', function ($value) {
        return State::where('code', $value)->firstOrFail();
    });

    Route::bind('shipping_method', function ($value) {
        return ShippingMethod::where('id', $value)->firstOrFail();
    });

    Route::bind('payment_method', function ($value) {
        return PaymentMethod::where('id', $value)->firstOrFail();
    });

    Route::bind('taxon', function ($value) {
        return Taxon::where('slug', $value)->firstOrFail();
    });

    Route::bind('option', function ($value) {
        return Option::where('name', $value)->firstOrFail();
    });

    Route::bind('product_variant', function ($value) {
        return ProductVariant::where('sku', $value)->firstOrFail();
    });

    Route::bind('product_option_value', function ($value) {
        return ProductOptionValue::where('value', $value)->firstOrFail();
    });

    Route::bind('product_attribute_value', function ($value) {
        return ProductAttributeValue::where('value', $value)->firstOrFail();
    });

    Route::bind('channel', function ($value) {
        return Channel::where('hostname', $value)->firstOrFail();
    });

    Route::bind('locale', function ($value) {
        return Locale::where('code', $value)->firstOrFail();
    });

    Route::bind('currency', function ($value) {
        return Currency::where('code', $value)->firstOrFail();
    });

    Route::bind('exchange_rate', function ($value) {
        return ExchangeRate::where('currency_code', $value)->firstOrFail();
    });

    Route::bind('tax_category', function ($value) {
        return TaxCategory::where('code', $value)->firstOrFail();
    });

    Route::bind('tax_rate', function ($value) {
        return TaxRate::where('name', $value)->firstOrFail();
    });

    Route::bind('customer_group', function ($value) {
        return CustomerGroup::where('code', $value)->firstOrFail();
    });

    Route::bind('promotion', function ($value) {
        return Promotion::where('code', $value)->firstOrFail();
    });

    Route::bind('product_review', function ($value) {
        return ProductReview::where('title', $value)->firstOrFail();
    });

    Route::bind('cms_page', function ($value) {
        return CmsPage::where('slug', $value)->firstOrFail();
    });

    Route::bind('cms_block', function ($value) {
        return CmsBlock::where('name', $value)->firstOrFail();
    });

    Route::bind('menu', function ($value) {
        return Menu::where('code', $value)->firstOrFail();
    });

    Route::bind('menu_item', function ($value) {
        return MenuItem::where('code', $value)->firstOrFail();
    });

    Route::bind('role', function ($value) {
        return Role::where('name', $value)->firstOrFail();
    });

    Route::bind('permission', function ($value) {
        return Permission::where('name', $value)->firstOrFail();
    });

    Route::bind('admin_user', function ($value) {
        return AdminUser::where('email', $value)->firstOrFail();
    });

    Route::bind('admin_role', function ($value) {
        return AdminRole::where

Please or to participate in this conversation.