From da8d05323cb86e6e4cbc110da2ddc9b631f05a63 Mon Sep 17 00:00:00 2001 From: HenriqueVilela Date: Fri, 25 Nov 2022 12:43:09 -0300 Subject: [PATCH] chama a index do angular pelo laravel --- back/app/Http/Controllers/AppController.php | 27 +++++++++++++++++++++ back/app/Providers/RouteServiceProvider.php | 2 +- back/public/index.php | 3 +++ back/routes/web.php | 21 +++++++++++++++- front/src/index.html | 1 + 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 back/app/Http/Controllers/AppController.php diff --git a/back/app/Http/Controllers/AppController.php b/back/app/Http/Controllers/AppController.php new file mode 100644 index 0000000..9b1591b --- /dev/null +++ b/back/app/Http/Controllers/AppController.php @@ -0,0 +1,27 @@ +render(); + // return view('', ['ssr' => $ssr]); + // echo file_get_contents(base_path().'/../front/src/index.html'); + } + +} + diff --git a/back/app/Providers/RouteServiceProvider.php b/back/app/Providers/RouteServiceProvider.php index 3bd3c81..927be5d 100644 --- a/back/app/Providers/RouteServiceProvider.php +++ b/back/app/Providers/RouteServiceProvider.php @@ -26,7 +26,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string|null */ - // protected $namespace = 'App\\Http\\Controllers'; + protected $namespace = 'App\\Http\\Controllers'; /** * Define your route model bindings, pattern filters, etc. diff --git a/back/public/index.php b/back/public/index.php index 1d69f3a..8b48781 100644 --- a/back/public/index.php +++ b/back/public/index.php @@ -3,6 +3,7 @@ use Illuminate\Contracts\Http\Kernel; use Illuminate\Http\Request; + define('LARAVEL_START', microtime(true)); /* @@ -53,3 +54,5 @@ )->send(); $kernel->terminate($request, $response); + + diff --git a/back/routes/web.php b/back/routes/web.php index b130397..e0a1356 100644 --- a/back/routes/web.php +++ b/back/routes/web.php @@ -1,6 +1,8 @@ '; + $indexHtml = File::get(base_path().'/../front/dist/front/index.html'); + $indexHtml = str_replace("", $metaTags , $indexHtml); + + return $indexHtml; + } else { + header('Content-Type: application/javascript; charset=UTF-8', true); + $contents = File::get(base_path().'/../front/dist/front/'.$angular); + $response = Response::make($contents, 200); + $response->header ('Content-type', 'application/javascript'); + return $response; + } +})->where('angular', '.*'); \ No newline at end of file diff --git a/front/src/index.html b/front/src/index.html index 1617a38..2d1fa24 100644 --- a/front/src/index.html +++ b/front/src/index.html @@ -1,6 +1,7 @@ + Front