How to pass a CSRF token safely to a separate VueJS frontend?

纵然是瞬间 提交于 2021-01-28 06:29:34

问题


Laravel(backend) and VueJS(frontend created with Vue CLI) are separated, hence have different domains and repositories. I am wondering what is the best way to pass a CSRF token from Laravel to VueJS safely.

I've found some old questions here and on Laracasts but they are either irrelevant, outdated or have no answer. Here are a few:

Pass csrf token from Laravel to Vue

Creating a sign up token for Laravel app from separate frontend app

(Laracasts forum) CSRF in separate angular app

I am aware that Laravel ships with $except array in VerifyCSRFToken middleware. Adding frontend's URL to this list will create a security flaw, am I correct?


回答1:


In case of using a standalone application (vue, react, angular ....) the best solution is to use Laravel Passport instead of using CSRF tokens.



来源:https://stackoverflow.com/questions/59389557/how-to-pass-a-csrf-token-safely-to-a-separate-vuejs-frontend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!