I have a Laravel 5 application as the backend, serving AngularJS from a different directory (which is now assigned as the public path of Laravel) using this code on my
bootstrap/app.php
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__.'/../../../client';
});
Then on routes.php
Route::get('{angular?}', [ 'uses' => 'HomeController@index' ])->where('angular', '.*');
Last the controller will just return the index.html file on the AngularJS directory
// HomeController@index
public function index()
{
return \File::get(public_path().'/index.html');
}
The problem I'm having is that the scripts are not being loaded and when viewing it in chrome inspector looking at the resources, for example app.js
all it contains is the entire index.html
and because of this I'm getting the
Unexpected Token <
The reason I separated AngularJS directory and not serve it from app/public
is that there other backend framework involved.
When you changed the location of the public directory, did you copy all the assets that were in laravel\public to the new directory?
@basementjack I'm trying to follow the example set here
So yes, I think I have moved most of the files. Not unless you mean I also need to move the .htaccess file?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community