Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

boletinho's avatar

405 (Method Not Allowed) - Laravel and Vue.Js

Good afternoon everyone, I'm trying to implement a notification system with the possibility to mark this notification with a like.

I am using laravel 7 for the back end and vuejs for the front end.

The code works correctly on localhost, but when I deploy to Heroku it stops working and to give me the message below.

http://springalert.herokuapp.com/api/like 405 (Method Not Allowed)
Uncaught (in promise) Error: Request failed with status code 405
at createError (app.js:5347)
at settle (app.js:5608)
at XMLHttpRequest.handleLoad (app.js:4816)

Someone with any tips for the subject, I researched about it and I know that we have to configure CORS but for this version of laravel it supposedly would no longer be necessary.

follow the code, thank you for your help.

ROUTE

Route::post('/api/like/', 'NotificationController@api_like');

CONTROLLER

public function api_like(Request $request) {
  $like = new Like;
  $like->notification_id = $request->id;
  $like->user_id = auth()->id();
  $like->save();
}

VUEJS

<b-card-text class="text-right" v-if="Object.keys(notification.like).length == 0">
   <a @click="makelike('success', 'Informação', notification.id)" class="a"><i class="fas fa thumbs-up"></i></a>
</b-card-text>
      makelike(variant = null, title, notification_id) {
        this.id = notification_id
        axios.post('api/like/',{ id:this.id })
                    .then((response) => {
                      this.set_notifications()
                      this.$bvToast.toast('Obrigado pela tua visualização', {
                        title: title,
                        variant: variant,
                        solid: true
                      })
                    })
      },

0 likes
7 replies
bugsysha's avatar

Someone with any tips for the subject, I researched about it and I know that we have to configure CORS but for this version of laravel it supposedly would no longer be necessary.

How can it not be necessary?

1 like
boletinho's avatar

I had already researched this and effectively this version of Laravel already assures that.

bugsysha's avatar

Are Vue app and Laravel backend on the same domain?

bugsysha's avatar

To me, it seems that it is working.

HTTP/1.1 419 unknown status
bugsysha's avatar

Yes

CORS is a mechanism that allows restricted resources on a web page to be requested from the frontend domain to the backend domain.

So if frontend and backend are on the same domain there is no CORS.

Is working in localhost, in Heroku dont

I've tested Heroku and it is throwing 419 which is CSRF token issue. So to me, it seems that it is working. You are probably making wrong assumptions.

Please or to participate in this conversation.