Route issue

Published 2 years ago by cipsas

Hi,

when I try to make post request, somehow it goes to index method instead post method. When I check: php artisan route:list

POST                           | api/pages                        | api.pages.store   

I try to make post request with vue-resource:

var resource = this.$resource('/api/pages/:id');
resource.save({page: this.page} , function (data, status, request) {});

and try to test with chrome app POSTMAN, and get the same result.

Any ideas what could be wrong?

Best Answer (As Selected By cipsas)
cipsas

No, with csrf token is everything fine.

I figure out . I'm using laravel-localization package and I accidentally put api routes under localizationRedirect middleware. This middleware redirect from '/api/pages' to '/en/api/pages', which cause an issue.

RomainLanz

What's the content of your stores() method?

cipsas
cipsas
2 years ago (40,820 XP)

just two simple lines for test:

    public function store( Request $request )
    {
        \Log::info('from store');
        return;
}
Snapey
Snapey
2 years ago (1,040,195 XP)

is your request being caught by middleware because you did not pass csrf token?

cipsas
cipsas
2 years ago (40,820 XP)

No, with csrf token is everything fine.

I figure out . I'm using laravel-localization package and I accidentally put api routes under localizationRedirect middleware. This middleware redirect from '/api/pages' to '/en/api/pages', which cause an issue.

Please sign in or create an account to participate in this conversation.