1
votes

I am using vuejs + nuxtjs when i try to delete record using axios post it given the cors policy error and it given 405 method not found my url is like below which i used for delete functionality.

In my browser headers given like this Request URL: http:///remove_homework_file/573 Request Method: OPTIONS Status Code: 405 METHOD NOT ALLOWED Remote Address: 52.76.74.61:80 Referrer Policy: no-referrer-when-downgrade

My delete code is like below.

return  axios.post(http://<url>/remove_homework_file/573, {
        params: {
          sbtoken: localStorage.getItem('token'),
          class_session_id: 573,
          line_id:33
        },
        jsonrpc: 2.0,
        method: 'call'
      }).then(function (response) {
                    //currentObj.output = response.data;
                })
                .catch(function (error) {
                    //currentObj.output = error;
                });

We already used axios post,delete,xmlhttprequest all given 405 what should we do? I didn't get any response it always given me 405 method not allowed.Can you please help for this?

1
Maybe the setup of the route doesn't accept post, delete, patch methods. Can you please include the route setup? - rkg
Assuming the URL is correct it would appear that you don't have CORS configured correctly on your server. We would need to know more about your server to advise further. - skirtle

1 Answers

1
votes

As said in THIS article:

A 405 Method Not Allowed Error is an HTTP response status code that indicates a web browser has requested access to one of your web pages and your web server received and recognized its HTTP method. But, unfortunately, your server has decided to reject that specific HTTP method, so the web browser can’t access the requested web page.

So it suggests three things you can try in order to solve your error. Maybe you could check your server logs and configuration files as your code seems fine to me.