jadjoubran / laravel5-angular-material-starter

Get started with Laravel 5.3 and AngularJS (material)
https://laravel-angular.readme.io/
MIT License
1.66k stars 401 forks source link

remove hashtag # in url by angularjs #469

Closed saade closed 7 years ago

saade commented 7 years ago

I'm trying to remove the # from url, if i try to access: http://localhost:8000 my app works, but if i need to navigate to other page like: http://localhost:8000/home the page becomes blank.

i have done:

In my angular routes:

$locationProvider.html5Mode({
        enabled: true,
        requireBase: true
    });

on index.blade.php:

<base href="/">

and finally, after reading this thread: #407 in my handler.php:

public function render($request, Exception $e)
    {
        return view('index');
    }

but the page becomes blank.

saade commented 7 years ago

I had success with:

return response()->view('index', [], 404);

is this correct and safe to use?

jadjoubran commented 7 years ago

Hi @SaadeMotion Please take a look at this thread

jadjoubran commented 7 years ago

I don't think it's a good idea to return 404s

saade commented 7 years ago

Just return response()->view('index'); ??

jadjoubran commented 7 years ago

As noted here, you can enable HTML5 mode in ui-router by writing: $locationProvider.html5Mode(true) and then in Laravel you need a Catch all route