-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS prevents DELETE calls via XHR #150
Comments
Thanks, I forgot to Allow the DELETE method. Added it here: e63c654. Let me know if that works. |
Thanks, I just added OPTIONS as well: 75a126e |
Still doesn't work. I assume that the problem is not that the header you modified doesn't contain the My assumption is (haven't read through the code though since I'm not that much into Go) that you've got a switch statement or if block that filters out the path that the request comes in at and whether or not the method it uses is actually correct for that specific API endpoint. Since the You have to take into consideration that |
How are you testing it? |
I set up the socket by running the following commands in the browser console:
then initiating the actual request by running the following:
which then results in XMLHttpRequest cannot load http://localhost:18003/location?group=something&location=somethingElse. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. You have to remember that the code above triggers a request of the Note though that this URL endpoint is grabbed directly from the dashboard (since it uses that) but it doesn't matter the |
When sending an HTTP request to the
/locations
or/location
endpoint with theDELETE
method using JavaScript the browser sends an HTTPOPTIONS
request to ask the server whether or not this type of method is allowed for that specific endpoint. Since the FIND server apparently doesn't know how to handle this type of request it simply returns the dashboard page which (obviously) doesn't contain the appropriate header to tell the client's browser that theDELETE
request it is going to make is actually valid.This all is 'again' part of the Cross-Origin resource sharing specification that made up for some problems a few days ago. The solution would be to integrate a server-side check for requests using the
OPTIONS
method and returning a list of valid request types (for/locations
this would beDELETE
andGET
if I am not mistaken).To give an example of such a header:
For more detail please consider taking a look at this post over at StackOverflow.
Note that the documentation only contains
/locations
as a validDELETE
request endpoint but the dashboard actually uses/location
with different parametersThe text was updated successfully, but these errors were encountered: