In laravel/vuejs2 site with "vue-router": "^3 I need to open xlsx file with command :
fileurl = ‘http://localhost/tmp/test-item.xlsx’;
window.open(fileurl,'_blank');
from javascript.
But not found event catcher is triggered in resources/js/routes.js :
const router = new VueRouter({
routes,
mode: 'history'
});
router.beforeEach((to, from, next) => {
if (!to.matched.length) {
console.log('to.path::')
console.log(to.path)
alert( "::/not-found/" )
} else {
next();
}
})
If to copypaste url in fileurl in browser I have the same not found event catcher.
If there is a way to open filename in this case(this filename can be different in different cases) in browser by OS reader or some way to open xlsx file in some vuejs container ?
"vue": "^2.6.10"
"vue-router": "^3.0.7",
ATTEMPT TO SALVE :
I try to salve it in a different way and in file routes/web.php added line :
Route::get('/items/export-into-excel/{filename}', 'IndexController@exportIntoExcel')->name('exportIntoExcel');
and in IndexController.php file I added exportIntoExcel method, but it is not called when from javascript I call :
window.open('/items/export-into-excel/' + encodeURIComponent(res.data.excelFileUrl),'_blank');
But it does not work anyway, as action is run by vuejs router and laravel action is not called. If there is a way to bypass it somehow? Like all urls starting from some ‘/items/’ are not rendered by vuejs routes ?
ATTEMPT TO SALVE # 2: I found a hint to use skipAuth option, but adding in routes :
{
path: '/tmp/*',
meta: { skipAuth: true }
},
I do not have "Not Found" error anymore, but common layout of my site is opened with empty content. Actually I did not find any method like at skipAuth official docs at : https://v3.router.vuejs.org/ Please point where it is described? How else my issue can be salved ?
Thanks in advance!