Closed micobarac closed 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
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?
I assume that would include JWT token exchange between Angular and Laravel, like your older version of project used to do.
yes for authentication you'll have to setup JWT as explained in the docs
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?
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
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.
Ok, I see. It's a matter of choice what to do with root route. @jadjoubran, thanks for quick tips :).
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
Added angular install guide
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.