Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSRF token not found #1

Open
ajthinking opened this issue Nov 28, 2017 · 1 comment
Open

CSRF token not found #1

ajthinking opened this issue Nov 28, 2017 · 1 comment

Comments

@ajthinking
Copy link

Installing like this:

git clone [email protected]:blizzerand/Laravel5.5_And_React_demo.git react
cd react
composer install    
yarn && yarn run dev
# edited .env with database details
php artisan migrate --seed
php artisan key:generate

I am running on laravel valet so should be good to go at react.dev
But I get:

app.js:10445 CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token    

More specifically thats this section

var token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
  window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
  console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

Did I miss something?

@DanicicPredrag
Copy link

DanicicPredrag commented Jun 4, 2018

Add this line

meta name="csrf-token" content="{{ csrf_token() }}" ( put it inside html tag ofcorse )

in "head" part of welcome.blade.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants