Search code examples
laravelvue.jsbrowserroutesrefresh

Vue-Router breaks when reloading page with laravel-6


What is actually happening? If I refresh my web browser than doesn’t recognize anymore my route


Solution

  • Make sure you use route history, like this

    const router = new VueRouter({
      mode: 'history',
    });
    

    Everything that is not matched in previous routes will be served by the AppController, which returns the naked view that contains the files for bootstrapping the VueJS application. In your web routes put this one on the bottom of all your routes

     Route::get('/{path}', 'AppController@index')->where( 'path', "([A-z\d\-/_.]+)?" );
    

    see this article catch routes