Kevin Wakhisi
Kevin Wakhisi

Reputation: 48

Vue js laravel 8 routing

I am still confused when i try to add a route path in vue router such as :

{
        path: '/admin/blog/archived_blogs',
        name: 'ArchivedBlogs',
        meta: { title: 'Archived Blog' },
        component: ArchivedBlog
},

everything works fine apart from deleting where i get error 405(Method not allowed)

The POST method is not supported for this route. Supported methods: GET, HEAD.

all i can do is change the path to

{
   path: '/admin_blog_archived_blogs',
   name: 'ArchivedBlogs',
   meta: { title: 'Archived Blog' },
   component: ArchivedBlog
},

the current web route i use is

Route::get('/{slug?}', [HomeController::class, 'index'])->where('slug', '[\/\w\.-]*')->name('home');

Any advice ?

Upvotes: 1

Views: 1523

Answers (1)

Kamlesh Paul
Kamlesh Paul

Reputation: 12401

you need to use any() to catch all the methods as well

like

Route::any('/{slug?}', [HomeController::class, 'index'])->where('slug', '[\/\w\.-]*')->name('home');


for SPA i use

Route::any('{all}', [HomeController::class, 'index'])
    ->where('all', '^(?!api).*$')
    ->where('all', '^(?!storage).*$');

like this so all the web related route handle Vuejs and storage or api route handel by laravel

Upvotes: 3

Related Questions