please, I NEED HELP with homestead !!!!!.
I have a new install of the box and it keep giving me all PUT, PATCH, DELETE and OPTIONS http requests the 405 status, regardless of what my code does. I've try to call just a php file with an echo and a die() and only works for GET and POST, but the others give my an error message of status 405
Hello, i have tried recreating this issue. In my api.php file i have
Route::put('/test', function() {
return response()->json([
'test' => 'this works'
]);
});
And on the frontend i do
axios.put('/api/test')
.then(({ data }) => console.log(data));
And i get this response {test: "this works"}
So it all seems to work with the latest homestead for me.
What version of homestead are you running and how does you route look?
yah, we're going to need a lot more information to help with this issue.
Please post your entire Homestead.yaml file, which provider you are using, your host OS, and any modifications you have made to your Nginx configuration.
Also I would look in /var/log/nginx/error.log and /var/log/nginx/name-of-domain.log, and post any relevant info.
I've seen this many times. It only applies to /. If the url has any path at all it works fine.
Methods affected:
I'm guessing it's some nginx config thing or some odd default behavior.
Hmm, I have tried put and patch and delete on / and it does not work. However it does work if i make a request to /index.php. Seems like requests to / is requesting a file instead of a "route" and nginx won't allow put, patch, delete.
axios.delete('/').then(({data}) => console.log(data))
result:
DELETE http://example.com/ 405 (Not Allowed)
(anonymous) @ VM38:1
dispatchXhrRequest @ app.js:15943
xhrAdapter @ app.js:15777
dispatchRequest @ app.js:56619
Promise.then (async)
request @ app.js:56073
Axios.(anonymous function) @ app.js:56083
wrap @ app.js:15566
(anonymous) @ VM1408:1
app.js:15968 Uncaught (in promise) Error: Request failed with status code 405
at createError (app.js:15968)
at settle (app.js:56145)
at XMLHttpRequest.handleLoad (app.js:15842)
-----------------------------------------------------------------------
axios.delete('/index.php').then(({data}) => console.log(data))
result:
{test: "works"}
Sounds like an issue with your code and not Homestead.
Is not a problem with my code. @thecrypticace was totally right, it is a issue of nginx config on the Homestead. The rest of you just rambled about code without looking at my issue
Thanks @thecrypticace
I don't even think it's a Homestead configuration issue. I think it's an Nginx issue.
It is an nginx issue but is present in the homestead configuration of nginx. It's also present on forge.laravel.com servers.
I'm still looking for a fix that doesn't require adding index.php to the url.
For now I'm using method spoofing which is pretty nasty in this situation.
@oceanapplications I am like the same error. How to solve the problem?
I ended up going with method spoofing but I don't like that and would still like a real solution.
On January 22, 2021 at 12:42 GMT, Laércio Silva notifications@github.com wrote:
@oceanapplications I am like the same error. How to solve the problem?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.