L
L
lemonlimelike2018-09-14 16:46:04
Laravel
lemonlimelike, 2018-09-14 16:46:04

Error: Session store not set on request?

I am developing a project on laravel + vue. During authorization, an error occurs with status 500 and the error text: "Session store not set on request." It seems like the error is related to csrf_token, but I have it everywhere. Here is the form:

<form @submit.prevent="auth" method="POST">
        <input type="hidden" name="__token" :value="csrf">
        <div class="formIn__body__input">
            <input type="text" v-model="login" placeholder="Логин">
        </div>
        <div class="formIn__body__input">
            <input type="password" v-model="password" placeholder="Пароль">
        </div>
        <div class="formIn__body__input">
            <button type="submit" class="formIn__buttonSend">Войти</button>
        </div>
    </form>

Here is the script:
export default{
    data: () => ({
        formLogin:'border:none',
        login: null,
        password: null,
        csrf: window.laravel.csrf
    }),
    methods:{
        auth(){
            axios.post('api/login',{
                name: this.login,
                password: this.password,
                headers:{
                        'X-CSRF-TOKEN': this.csrf
                    }
            })
            .then(res => {
                console.log(res)
            })
            .catch(err => {
                console.log(err)
            })
        }
    }
}

Here is what I have in window.laravel
<script type="text/javascript">
    window.laravel = {!! json_encode([
            'user' => Auth::check(),
            'csrf' => csrf_token()
        ]) !!};
</script>

PS There is another project... It's the same as here, so everything works there, but nothing here!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
miki131, 2018-09-14
@lemonlimelike

You make a request to "/api", and there the session is not used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question