0

Laravel + Vue.js application routing not working properly. when i run laravel + vuejs application "http://127.0.0.1:8000/user" everything is working fine but when i run my application on xampp server using this url "http://localhost/Ecommerce/" then vue-router not working. For example when i click on my navigation link "users" then it will redirect to "http://localhost/user" instead of "http://localhost/Ecommerce/user" . Please help.

5
  • Please show us what your routes in both Laravel and vue-router are. Commented Nov 13, 2018 at 14:43
  • web.php Route::get('/', function () { return view('welcome'); }); Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); Route::get('{path}',"HomeController@index")->where( 'path', '([A-z\d-\/_.]+)?' ); Commented Nov 13, 2018 at 14:49
  • and app.js is require('./bootstrap'); window.Vue = require('vue'); import VueRouter from 'vue-router' Vue.use(VueRouter) const routes = [ { path: '/dashboard', component:require('./components/Dashboard.vue') }, { path: '/user', component: require('./components/User.vue') } ] Vue.component('example-component', require('./components/ExampleComponent.vue')); const router = new VueRouter({ mode: 'history', routes // short for routes: routes }) const app = new Vue({ el: '#app', router }); Commented Nov 13, 2018 at 14:50
  • thanks for reply @Delena Malan Commented Nov 13, 2018 at 14:52
  • if i am using Ip address instead of domain name its working fine. Commented Nov 13, 2018 at 14:58

1 Answer 1

5

Try adding a base url when you create you VueRouter, e.g.

new VueRouter({
    base: '/Ecommerce/', 
    routes: [...],
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.