Skip to content

axios.defaults.xsrfHeaderName does not work with Axios v1.13.5/InertiaJS v2.3.16 #97

@corneyl

Description

@corneyl

The value of axios.defaults.xsrfHeaderName is ignored by Axios v1.13.5 (at least in my project), this version is now included in the latest version of InertiaJS (v2.3.16).

While this might be an issue with Axios, there is another simple workaround to get it working, without waiting for Axios to fix this. Maybe this could be added to the docs?

We can configure the default visit options in the createInertiaApp call and set the "X-CSRFTOKEN" header:

createInertiaApp({
    ...
    defaults: {
        visitOptions: (href, options) => {
            return {
                headers: {
                    ...options.headers,
                    "X-CSRFTOKEN": window.cookie.csrftoken,
                },
            };
        },
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions