目前实践一个项目。有些小问题。可能想法错了,还望大家指点一下。 目录结构:
---vue-laravel
|
| ---- client #这是纯的 vue 目录
| ---- server #laravel 放在这里
laravel 提供 api 并且通过 CORS 解决跨域的问题。
目前认证这块是正常的。
但是我想把注册的模块也通过 vue 来实现页面展示, laravel 来存入数据库。但是,我使用 CORS 来提交数据会报 422 的错误。好像应该我没有把 CSRF 值传入的问题。
代码如下: vue 提交注册数据
handleRegisterFormSubmit () {
const postData = {
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
email: this.register.email,
password: this.register.password,
password_confirmation: this.register.password_confirmation,
name: this.register.name,
scope: ''
}
this.$http.post('http://localhost:8000/api/register', postData)
.then(response => {
console.log(response)
})
}
laravel Api 路由:
Route::post('/register',"Auth\RegisterController@register");
请问应该怎么来处理这种没有认证之前的前后端数据交互呢?谢谢