-
Notifications
You must be signed in to change notification settings - Fork 279
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
Simplified Javascript Access #8
Comments
Rob could you elaborate a bit more on your problem? The issue I have with adding this (I use aREST too) As it stands now depending on what you're doing it's becoming My solution to your particular problem I would solve another way cheers James Mills / prologic E: prologic@shortcircuit.net.au |
Thanks for your suggestions James, However the 30 byte overhead in my case is not much of a percentage I think my suggestion will offer considerable benefits for a small cost. So I don't have a problem to elaborate on now. I am just offering to Cheers, Rob Ward |
Yeah that's fine but we need to optimize the overall size of the aREST library. See Issue #3 because for one of my projects involving the Adafruit Motor Shield I basically run out of Flash (and I believe RAM). |
Ah ha, fair enough James. I can see the aREST would be a very I may be wrong but there could be others who may find my approach useful I have had a look over the rest of the project and the standard of the Anyway I would like to contribute something for benefits I have got thus Rob Ward On 07/07/14 21:00, James Mills wrote:
|
It seems to me that it should be a basic feature to be able to make rest api calls straight from web browser javascript code. Limiting the calls to go through proxy because 30 bytes seems overkill. |
On 14/10/14 11:35, tarmo888 wrote:
|
Old issue, headers have been added to aREST now, closing this :) |
Hi Marco, sorry to dig this one up. But while I see the header information has been added, I'm getting the same access error; XMLHttpRequest cannot load https://cloud.arest.io/xxxxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access. I'm creating a quick and dirty JS mockup and I'm trying to consume the output as JSON. Any thoughts? Cheers, |
I have come across this and I believe I solved the problem, however Have a look at what I did https://github.com/robwlakes/aREST only one It maybe useful to you, it may not. Cheers, Rob On 28/04/16 23:31, wblaircox wrote:
Rob Ward |
Hi Rob, can you link to the pull request you mentioned? Can't seem to find it :) |
Hi Marco, Sorry I am not up with GITHub procedures so I think I just cloned it, Due more to the fact I thought it was a very basic addition and you Here is my original GITHub link. and the line I added... client.println(F("Access-Control-Allow-Origin: *"));//Allows Browsers to It basically allows javascript and Adroid apps to access the server with I have tried to find my examples and I suspect I may have lost them in Fortunately I still have my MIT App builder project for Android that I Screen shot of the Android App. With any luck these maybe useful to you. Cheers, Rob On 08/05/16 04:03, marcoschwartz wrote:
Rob Ward |
Hi Marco,
I have been using your aREST library and admire your work. Thanks! I was keen not to have to add any thing to my browser's capability or set up anything to do with PHP on servers etc. That end I have worked out a way to allow Javascript to access the aREST commands using the XMLHttpRequest(). It looked ideal but threw errors as the browser was rejecting it Arduino on the basis it did not share its domain. I have discovered that adding the line
client.println(F("Access-Control-Allow-Origin: *"));
into the header allowed me access, and I did develop my simplified web page access.
I am a newbie to GitHub so I am not sure how to go about all this. I would like to submit my web page if you are interested for your perusal.
I am not sure how much this change to the header might compromise security generally (it appears to only involve the Arduino end?) or whether using the API was the answer to this problem. I will be interest to hear your comments.
Rob Ward
File: aREST.h
.......
template
void send_http_headers(T client){
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/json"));
client.println(F("Access-Control-Allow-Origin: *"));
client.println(F("Connection: close"));
client.println();
}
The text was updated successfully, but these errors were encountered: