1

I have a fresh laravel 5.4 installation, i run npm install and then proceed to test the example vue component, but nothing happens.

On my project's directory I run npm run dev and It compiles just fine. Then I execute php artisan serve and all I see is a blank page.

Here's my view, which is the only code I wrote:

<html>
    <head>
        <title>Laravel</title>
    </head>
    <body>
    <div id="app">
        <example></example>
    </div>
    <script src="/js/app.js"></script>
    </body>
</html>

Is that ok? am I missing something?

On my package.json, on devDepentencies, among other stuff I have: "vue": "^2.1.10"

Adocad
  • 731
  • 1
  • 11
  • 27

1 Answers1

3

It is because you didn't run php artisan make:auth so laravel didn't set the javascript object "Laravel" with "csrfToken" property.

In resources/assets/js/bootstrap.js, try to comment this line :

window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;

And recompile with npm run dev.

Kyllian Vinkler
  • 191
  • 1
  • 5
  • This solved it, thanks. If you or someone could share their quick opinion on php artisan make:auth; I know it's for quickly setting up the user authentication for new projects, but the application I'm gonna create is for a company that needs another sistem. The users will log in to my project using their credentials from their main database, however I will create a users table (in my projects db) copying their username and a couple of more fields, but wont allow them to edit that info. The can only edit a new field (an avatar). Should i use php artisan make:auth or handle this manually? – Adocad Apr 14 '17 at 11:10
  • 1
    The laravel `make:auth` authentification is easily editable to match with the developer needs. However, in your case, you can use your own authentification system for a better understanding and a more scalable code. – Kyllian Vinkler Apr 14 '17 at 11:28