jadjoubran / laravel-angular

(deprecated) Laravel & Angular package
https://laravel-angular.io
MIT License
179 stars 25 forks source link

Can you be more specific on installing Angular part #18

Closed micobarac closed 6 years ago

micobarac commented 6 years ago

Where do I run Angular Cli? Laravel root, resources folder...? How do you integrate and run Angular part with Laravel?

All these are pretty unclear.

Thanks.

jadjoubran commented 6 years ago

Thanks @micobarac Yes you're right, I will add these to the documentation during the weekend

My personal recommendation is to separate the 2 projects, so you'd run the angualr cli in a new folder outside of your Laravel project you serve both of these

I'll update this issue in the weekend when I update the docs

micobarac commented 6 years ago

Ok, @jadjoubran.

Another thing has crossed my mind, though. As I intensely use Java JHipster along with Angular, backend comes with user login, intended to protect backend API calls.

How do we achieve similar feature to make Laravel backend protected, as Laravel gets served on default port 8000, and Angular on 4200 by default?

micobarac commented 6 years ago

I assume that would include JWT token exchange between Angular and Laravel, like your older version of project used to do.

jadjoubran commented 6 years ago

yes for authentication you'll have to setup JWT as explained in the docs

micobarac commented 6 years ago

What do you actually do/show to user if Laravel on localhost:8000 accidentally gets opened in browser, as Angular holds the login screen in separate app?

jadjoubran commented 6 years ago

so your Laravel app will only be the API I personally like to return a 200 success as a means of quickly smoke testing the API you can decide to not serve anything, or show a specific page (depends on your use case) if you tell me about your use case I can maybe suggest something

micobarac commented 6 years ago

If Laravel is meant to serve API calls only, like Lumen, how do you hide or prevent access to Laravel home page on localhost:8000? Maybe by returning some 403 error and allowing only localhost:8000/api/* URLs? In Laravel <=> Angular integration, Laravel templating engine becomes obsolete.

micobarac commented 6 years ago

Ok, I see. It's a matter of choice what to do with root route. @jadjoubran, thanks for quick tips :).

jadjoubran commented 6 years ago

another way is to use Content Negotiation where you have to send a specific Accept header in order to access the API where you can also specify the API version This is not a security mechanism though but it does hide and won't be accessible from the browser, you'll have to use something like postman to add the headers

jadjoubran commented 6 years ago

Added angular install guide