LoginSignup
0
0

More than 5 years have passed since last update.

NodeJSからLaravel移行時につまづいた点

Last updated at Posted at 2018-10-14

1. ajax利用時にCSRFトークン利用が必須

下記が該当Issue
https://stackoverflow.com/questions/46466167/laravel-5-5-ajax-call-419-unknown-status

bladeファイルでCSRFトークンを生成し、ajax利用するJSファイルでその値をヘッダに付加する必要がある.

hoge.blade.php
{{--  LaravelでajaxするときにCSRFトークン生成が必須  --}}
<meta name="csrf-token" content="{{ csrf_token() }}">
hoge.js
$.ajaxSetup({
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
  });

他の点は見つけ次第update予定

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0