Laravel Vue js spa application

流过昼夜 提交于 2019-12-08 01:48:59

问题


1).

i want to know why people use two servers to make a vuejs SPA with laravel.
I think we can use the other way. Make a Route like this

 Route::get('{any}', function () {
    return view('index');
})->where('any' , ".*");

and let vue handle the page url.. why people are using 2 servers and then using laravel passport to authenticate when we dont need to do all this to make spa..

2).

Okay now suppose we have our spa readdy using 2 separate servers one for vue and one for laravel.
Now i don't know how to set two servers on a single remove server.? how should i upload both vue and laravel applications on a single server on internet and make them work together.


回答1:


I think this is a bit of religion of some sort, but there is no right or wrong answer. Both have benefits and disadvantages.

A few of the benefits I can think of on top of my head is:

Reusability. You've made an API now everyone and everything can use this API, wanna make an IOS app to your web application as well? Well, go right on you have a 100% functional and tested API already.

Expertise: It's easy for your team to split up and work on what they know.

Deployment: Frontend and backend can be deployed, and tested, separately which can give you a big amount of freedom.

So basically how you could set this up very fast. is install a laravel/lumen application where you have the API serve with your preferred choice homestead, nginx, artisan serve etc.

then take a new vuejs/ReactJS etc. server and set it up. then all your API calls referer to the localhost your Laravel application is running on.



来源:https://stackoverflow.com/questions/49181611/laravel-vue-js-spa-application

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