Skip to content

Set x-xsrf-token and send it in header during request RTK Query #3031

@Neo363

Description

@Neo363

I have Laravel API + NextJs application with Sanctum authentication.

With Sanctum before sending request to the route, you need to send a request to /sanctum/csrf-cookie 'to initialize csrf protection'.

Here i how my RTK Query API looks:
vcq4T

Here is how the functions are called:
MWFwJ

The logic works fine but i wanted to use only RTK Query and not depend on axios. Also, is there any way to handle getting the csrf-cookie and send it during the request from createAPI()?

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