Skip to content

Commit

Permalink
chama a index do angular pelo laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueVilela committed Nov 25, 2022
1 parent 0c94537 commit da8d053
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
27 changes: 27 additions & 0 deletions back/app/Http/Controllers/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers;


use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Routing\Route;

class AppController extends Controller
{
private function render()
{
// $renderer_source = File::get(base_path().'/../front/src/index.html');
return 'teste';
}

public function get(Request $request)
{
// $ssr = $this->render();
// return view('', ['ssr' => $ssr]);
// echo file_get_contents(base_path().'/../front/src/index.html');
}

}

2 changes: 1 addition & 1 deletion back/app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions back/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;


define('LARAVEL_START', microtime(true));

/*
Expand Down Expand Up @@ -53,3 +54,5 @@
)->send();

$kernel->terminate($request, $response);


21 changes: 20 additions & 1 deletion back/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;

/*
|--------------------------------------------------------------------------
Expand All @@ -13,6 +15,23 @@
|
*/

Route::get('/', function () {
Route::get('/welcome', function () {
return view('welcome');
});


Route::get('{angular?}', function($angular = '') {
if (strpos($angular, '.') === false) {
$metaTags = '<meta name="description" content="teste"><meta name="robots" content=""><meta name="author" content="teste">';
$indexHtml = File::get(base_path().'/../front/dist/front/index.html');
$indexHtml = str_replace("<!--meta tags-->", $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', '.*');
1 change: 1 addition & 0 deletions front/src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!doctype html>
<html lang="en">
<head>
<!--meta tags-->
<meta charset="utf-8">
<title>Front</title>
<base href="/">
Expand Down

0 comments on commit da8d053

Please sign in to comment.