javascript - Remove the # hash from URL when using Vue.js in Laravel Homestead -


i have laravel 5.2 setup running in homestead , using vue.js router build spa. i'm trying remove #hash url know can done, keep getting errors:

i've added rewrite ^(.+)$ /index.html last; vhosts file in homestead:

server {      listen 80;     listen 443 ssl;     server_name app.myproject.dev;     root "/home/vagrant/code/vibecast/app.myproject.com/public";      rewrite ^(.+)$ /index.html last;      index index.html index.htm index.php;      charset utf-8;      ...  } 

when restart , open page 500 internal server error.

is there need added routes in laravel?

var router = new vuerouter({     hashbang: false,     history: true,     linkactiveclass: "active" }) 

i can working without #hash (or modified hosts file) when navigating around, fails when reload page.

i've managed find solution, via matt stauffer's demo app. first, no need update vhosts file. need update spa/vue.js route in routes.php to:

route::get('/{vue?}', 'appcontroller@spa')->where('vue', '[\/\w\.-]*'); 

and of course initialise vue.js router so:

const router = new vuerouter({     history: true,     hashbang: false,     linkactiveclass: 'active' }) router.mode = 'html5' 

ref: https://github.com/mattstauffer/suggestive/blob/master/app/http/routes.php#l9


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -