Pass csrf token from Laravel to Vue

前端 未结 1 1653
说谎
说谎 2021-01-20 04:09

Pass csrf token from Laravel to Vue I have a separate Vue app for client and Laravel for back-end (API). I use Cookies so I need csrf prote

相关标签:
1条回答
  • 2021-01-20 04:56

    Take a look at this documentation

    If you add this to your blade template in the head then you can always pull the CSRF token from there

    <meta name="csrf-token" content="{{ csrf_token() }}">
    

    And you can then fetch said CSRF token by doing this

    $('meta[name="csrf-token"]').attr('content')
    
    0 讨论(0)
提交回复
热议问题