How can I implement Laravel 5.5 and Angular 4 project intogether?

后端 未结 2 775
再見小時候
再見小時候 2021-02-06 17:28

If I want to implement Angularjs 4 or 2 with Laravel 5.5 (angular will consume the API from laravel), what should be the best method? 1) Should I create two folders in xampp/htd

2条回答
  •  死守一世寂寞
    2021-02-06 18:10

    what if you want to: have laravel website at: http://site.localhost and have an Angular admin inside that, at: http://site.localhost/admin

    I tried to put resources at root of laravel public (assets & js), make my view in resources/views/admin with:

    Route::get('/admin', function () {
        View::addExtension('html', 'php');
        return View::make('admin.index');
    } )->name('admin');
    

    and build with ng build --prod --aot --base-href /admin

    the problem is now that the base href also applies to CSS, so loading fontawesome looks for: http://site.localhost/admin/assets/fonts/fontawesome-webfont.ttf?v=4.7.0

    but my assets are on root of public not inside "admin", and if I add an "admin" folder inside public, I get a 'Forbidden' page on site.localhost/admin...

提交回复
热议问题