Axios PUT options ok, but not doing the real call (POST does work)
up vote
1
down vote
favorite
Am a bit confused about what is happening here. I have done all my CORS research and made it work with my POST and GET request, that is all fine and shining. But now I needed a PUT request (cause put stands for update). And my OPTIONS request is all fine but it is not doing the real call. If i change the methods to POST, in laravel and Axios (in VueJs), it works. Anyone has a clue, here is my response from server:
Versions:
- Axios - 0.18.0 (latest release)
Any more information required, let me know and I will try my best to provide that.
UPDATE: sorry i made a typo in my last sentence: "If i change the methods to PUT, in laravel and Axios (in VueJs), it works"
Methods should be POST not PUT, so like this: "If i change the methods to POST, in laravel and Axios (in VueJs), it works"
laravel vue.js axios
add a comment |
up vote
1
down vote
favorite
Am a bit confused about what is happening here. I have done all my CORS research and made it work with my POST and GET request, that is all fine and shining. But now I needed a PUT request (cause put stands for update). And my OPTIONS request is all fine but it is not doing the real call. If i change the methods to POST, in laravel and Axios (in VueJs), it works. Anyone has a clue, here is my response from server:
Versions:
- Axios - 0.18.0 (latest release)
Any more information required, let me know and I will try my best to provide that.
UPDATE: sorry i made a typo in my last sentence: "If i change the methods to PUT, in laravel and Axios (in VueJs), it works"
Methods should be POST not PUT, so like this: "If i change the methods to POST, in laravel and Axios (in VueJs), it works"
laravel vue.js axios
Do thePUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.
– Core972
Nov 19 at 15:30
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
That's the response to theOPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's aPUT
request. All CORS security checks are imposed client-side
– apokryfos
Nov 19 at 15:54
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Am a bit confused about what is happening here. I have done all my CORS research and made it work with my POST and GET request, that is all fine and shining. But now I needed a PUT request (cause put stands for update). And my OPTIONS request is all fine but it is not doing the real call. If i change the methods to POST, in laravel and Axios (in VueJs), it works. Anyone has a clue, here is my response from server:
Versions:
- Axios - 0.18.0 (latest release)
Any more information required, let me know and I will try my best to provide that.
UPDATE: sorry i made a typo in my last sentence: "If i change the methods to PUT, in laravel and Axios (in VueJs), it works"
Methods should be POST not PUT, so like this: "If i change the methods to POST, in laravel and Axios (in VueJs), it works"
laravel vue.js axios
Am a bit confused about what is happening here. I have done all my CORS research and made it work with my POST and GET request, that is all fine and shining. But now I needed a PUT request (cause put stands for update). And my OPTIONS request is all fine but it is not doing the real call. If i change the methods to POST, in laravel and Axios (in VueJs), it works. Anyone has a clue, here is my response from server:
Versions:
- Axios - 0.18.0 (latest release)
Any more information required, let me know and I will try my best to provide that.
UPDATE: sorry i made a typo in my last sentence: "If i change the methods to PUT, in laravel and Axios (in VueJs), it works"
Methods should be POST not PUT, so like this: "If i change the methods to POST, in laravel and Axios (in VueJs), it works"
laravel vue.js axios
laravel vue.js axios
edited Nov 19 at 16:01
asked Nov 19 at 15:23
Niels Lucas
72112
72112
Do thePUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.
– Core972
Nov 19 at 15:30
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
That's the response to theOPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's aPUT
request. All CORS security checks are imposed client-side
– apokryfos
Nov 19 at 15:54
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56
add a comment |
Do thePUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.
– Core972
Nov 19 at 15:30
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
That's the response to theOPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's aPUT
request. All CORS security checks are imposed client-side
– apokryfos
Nov 19 at 15:54
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56
Do the
PUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.– Core972
Nov 19 at 15:30
Do the
PUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.– Core972
Nov 19 at 15:30
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
That's the response to the
OPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's a PUT
request. All CORS security checks are imposed client-side– apokryfos
Nov 19 at 15:54
That's the response to the
OPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's a PUT
request. All CORS security checks are imposed client-side– apokryfos
Nov 19 at 15:54
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Ok, so I had to put a header for allowing the PUT method:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); <----
First I did not had that header, but my GET and POST worked fine, so default header is set for only GET/POST maybe? Now I defined all the methods by myself and now it is working. I know this can be better done in Laravel with a cors package or make an middleware, but I will do that in the future. For now this works.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Ok, so I had to put a header for allowing the PUT method:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); <----
First I did not had that header, but my GET and POST worked fine, so default header is set for only GET/POST maybe? Now I defined all the methods by myself and now it is working. I know this can be better done in Laravel with a cors package or make an middleware, but I will do that in the future. For now this works.
add a comment |
up vote
0
down vote
Ok, so I had to put a header for allowing the PUT method:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); <----
First I did not had that header, but my GET and POST worked fine, so default header is set for only GET/POST maybe? Now I defined all the methods by myself and now it is working. I know this can be better done in Laravel with a cors package or make an middleware, but I will do that in the future. For now this works.
add a comment |
up vote
0
down vote
up vote
0
down vote
Ok, so I had to put a header for allowing the PUT method:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); <----
First I did not had that header, but my GET and POST worked fine, so default header is set for only GET/POST maybe? Now I defined all the methods by myself and now it is working. I know this can be better done in Laravel with a cors package or make an middleware, but I will do that in the future. For now this works.
Ok, so I had to put a header for allowing the PUT method:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); <----
First I did not had that header, but my GET and POST worked fine, so default header is set for only GET/POST maybe? Now I defined all the methods by myself and now it is working. I know this can be better done in Laravel with a cors package or make an middleware, but I will do that in the future. For now this works.
answered Nov 20 at 8:24
Niels Lucas
72112
72112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377743%2faxios-put-options-ok-but-not-doing-the-real-call-post-does-work%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do the
PUT
method is allowed for this route in laravel. If you use Laravel-cors check if the method is allowed too.– Core972
Nov 19 at 15:30
@Core972 isnt the 'Allow: PUT' more then enough to know? and if it wasnt allowed, should the status code not have been 200 but 400?
– Niels Lucas
Nov 19 at 15:35
That's the response to the
OPTIONS
call which tells the client what's allowed in the CORS request. It will not send a 400 error because it does not yet know what request you intend to do. The browser will just not make the request unless it's aPUT
request. All CORS security checks are imposed client-side– apokryfos
Nov 19 at 15:54
Did you create routes for both the options and the put request? I had a similar issue not too long ago
– mur762
Nov 19 at 19:34
@mur762 options should not be a route method. Its just a cors thing. I do know that it is possible to create a options route in laravel, but i have not really looked into it. But it works now, see my own answer
– Niels Lucas
Nov 20 at 8:56