1

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 ?

1
  • Route::get says it's a GET route, change to Route::post if you want a POST route Commented Apr 16, 2021 at 9:20

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

when bringing in Vue router 4 into a Laravel 8 app...is it possible to use Vue Router for some vue components routing and then have completely separate unrelated routing using Laravel 8 web routes? For example in my app Vue router keeps looking for a / route when I load my dashboard...but I don't have a Main or Home Vue component...instead I load my Laravel apps dashboard using a web route in Web.php. How do I handle a scenario like this?
@PA-GW have you tried above solution ?
I have not...before implementing I wanted to ask if I would need to do this for EVERY single controller/web route I have...which is about 50. I see it applied to a HomeController::class above only. Also, how does it know to handle Vue.js routes? I see the regex for api and storage in the where clauses but not any regex for vue? Thank you for your time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.