Receiving Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response. when trying to unlike a post. My PUT, POST, and GET calls are working via the discourse API using tokens. Anybody run into this?
AI-generated summary
david_dav reported encountering a CORS error (Method DELETE is not allowed by Access-Control-Allow-Methods) when attempting to un-like a post via the Discourse API using tokens, while their PUT, POST, and GET requests function correctly. sam inquired if the issue persisted on the latest version and suggested inspecting the full request sequence in Chrome Dev Tools to verify if DELETE was explicitly blocked. Mittineague tested the functionality on meta.discourse.org and confirmed that DELETE requests for un-like actions return a 200 status code, indicating the server is not explicitly disallowing the method. david_dav clarified they are using the latest hosted version with token authentication. They provided a preflight OPTIONS request log showing the access-control-request-method set to DELETE and the access-control-request-headers including x-http-method-override, yet the preflight response still rejects the method, suggesting a configuration mismatch between the client’s override header and the server’s allowed methods.
Is this on latest, have a look at the full sequence in chrome dev tools, are we explicitly disallowing DELETE?
Looking in Network it doesn’t look that way.
I just Liked and then ninja unLiked your post.
Like
Request URL:https://meta.discourse.org/post_actions
Request Method:POST
Status Code:200
unLike
Request URL:https://meta.discourse.org/post_actions/233725
Request Method:DELETE
Status Code:200
We are using the latest hosted version and authentication via token. We are accessing via API endpoints.
Request URL:https://example.com/post_actions/264?api_key=<key>&api_username=Testddd-dev-5369&post_action_type_id=2
Request Method:OPTIONS
Status Code:200
Remote Address:55.55.55.55:443 <fake ip>
:authority:example.com
:method:OPTIONS
:path:/post_actions/264?api_key=<key>&api_username=Testddd-dev-5369&post_action_type_id=2
:scheme:https
accept:*/*
accept-encoding:gzip, deflate, sdch, br
accept-language:en-US,en;q=0.8
access-control-request-headers:x-http-method-override
access-control-request-method:DELETE
dnt:1
origin:http://localhost:3000
referer:http://localhost:3000/thread-details/202
user-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1