-
Notifications
You must be signed in to change notification settings - Fork 119
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
Support for OPTIONS request for CORS reasons #152
Comments
Hi there! When you do the You can test with
|
Thanks for the response! Here is my command, and the response. Seems like it's correctly returning the header, as expected:
A few things to note: Our endpoint is dangled off of the main page handler - wouldn't our endpoint returning the CORS header as shown above come AFTER the preflight failure, meaning it would never have a chance to take effect? That matches what we're seeing in practice; When any of our Seasocks REST endpoints are hit, we typically see a journal that we're servicing endpoint "X/Y/Z". We're not seeing that here, so it seems like it's dead ended before it even has a chance to return that header. |
It actually looks like it's in there twice.... and yes, grepping the code we already put So, as best I can tell the CORS is working...but my guess is the "preflight" it's talking about is doing a |
OK, here's a Wireshark trace from what we're seeing. In this case, we have a PC running Chrome attempting to access the embedded Linux device running seasocks with page handlers - with a GET request of 'http://192.168.137.138/system/serial-number. The Chrome application returns the following error information:
|
Hi! Can you attach the packet capture itself instead of the text? It's much easier to debug in wireshark than in a text editor :) thanks! |
ah!
is what was sent, which we don't support I think? Hard to tell |
Sorry, here's the full trace (I hope). Unfortunately, getting this secondhand, as I'm having device/networking issues. The request should have been a GET of this URL: 'http://192.168.137.138/system/serial-number'. |
We believe that the OPTIONS call is the pre flight check to ensure that the web domain is allowed to call that API. (Sorry, I'm not a HTTP expert; We believe this is part of the standard, so I'll apologize upfront if I have this wrong). |
Right! That seems to be what's happening here. We'll need to support |
Hello,
We are using Seasocks on our custom built embedded Linux mobile device to serve up static endpoints that act as a remote control testing API to our device. We are mapping these REST endpoints to C++ functions. This would be something like this:
PUT /arithmetic/add?param1=2¶m2=4
In our code, this is done by creating a a RootPageHandler object and adding the URL paths to this.
We are looking to add CORS to our API, so that if our device is sharing a local network connection with a host PC, a web browser on that host PC can call through to our device, and keep the data private and in the local loop. However, the only ability I see to add CORS is through the web socket handers:
We attempted to add a header on our endpoints like this:
writer->header("Access-Control-Allow-Origin", "*");
, but this appears to be too far downstream and the browser returns the following error: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://xxxxx/system/serial-number. (Reason: CORS preflight response did not succeed).Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.".
Is it possible to add CORS to the prefllight traffic? Is there an easier way to do this using Seasocks? Thank you in advance
The text was updated successfully, but these errors were encountered: