2

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.

6
  • Where are you seeing examples of two servers? Are you referring to the web server and webpack dev server? Commented Mar 8, 2018 at 20:16
  • yes one is webpack server and one is laravel server .. but that is the second point. i have to make a spa and firstly i got to know why people are using these 2 servers instead of just using the other way i discribed above. and if they are using it how are they gonna combine them. Commented Mar 8, 2018 at 20:21
  • 1
    1. you can do it like this, yes. 2. it can also make sense to separate API server and application (vue). For example, if API is hosted on whole other doman, so they can be deployed independently. If it's the same machine it makes sense to use single server like in 1. Commented Mar 8, 2018 at 20:21
  • 1
    It's important to first understand what the webpack dev server actually is and what it's doing. It is not a production tool. It's there for development purposes so you can utilize things like watch and hot reloading. It does not supplant or compliment the web server outside of a development environment. And as to your question about the catch all route, you'll need that regardless as it allows direct browser navigation within the SPA. Commented Mar 8, 2018 at 20:26
  • okay @dfsq i got you. thank you for this. but i wan't to know one more thing.. there isn't any sense or there is no way that we can upload an application which is made by using two servers and upload the application on one server ..? i just want to know can we or we cant .? Commented Mar 8, 2018 at 20:28

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you this is answer of my first point. totally get it. i just want to know 1 more thing. if someone has an application which is made using a vue dev server and a laravel server.. can we upload both the applications on a single server online .??
Well yes you can, i don't see the reason to do this, except it might save you 5$ (on a low server) a month :) But it's indeed possible
You are the best @casper

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.