Stelios k
Stelios k

Reputation: 1

Angular 6 project inside laravel blade

I am using angular 6 project in a laravel backend. I build the project with --prod and -base-href = /public/angular/dist/ and everything is great. Now i load the index html file from public/angular/dist/index.html inside a laravel blade:

include base_path()./public/angular/dist/index.html';

The blade loads perfectly the static angular deployed html file but my only problem is that the url turn into

mydomain.com/public/angular/dist

I tried with htaccess to rewrite the url but I couldn't make it. Is there any way u can help me?

Upvotes: 0

Views: 1049

Answers (2)

Sivakumar
Sivakumar

Reputation: 56

it will works : 1. Build your angular app with following cmd :

ng build --prod --output-path pwa-app--base-href /pwa-app/
  1. Copy paste angular project build to your laravel application

enter image description here

3.Go to resources > views . Create app.php and paste the following code

<?php readfile("./pwa-app/index.html"); ?>

4.Add the following route inside web.php

Route::any('/pwa-app/{any?}',function() { return view('app'); });

5.Try !!!

yourdomain/pwa-app

I hope this will works ...

Upvotes: 0

As I understand, the combination of Angular 2+ and Laravel are meant to be separated projects.

In the backend you make an api with Laravel and then you can consume it from any front end: angular, react, android, etc.

In the frontend you make a service that fetch the api urls in the backend and that url responses a json, it may be in example, a list of users.

Upvotes: 2

Related Questions