I need to create a service that accepts JSON get requests from outside
domains. When I try to make the request on an outside domain I get error:
"No 'Access-Control-Allow-Origin' header is present on the requested
resource."
I have the following code in my app's default.py:
def call():
return service()
@service.jsondef SmallTest(a, b):
response.headers['Access-Control-Allow-Origin'] = '*' # or restrict
access to specific origins
return response.json(a + b)
If I access the resource directly (type
'myappurl/call/json?SmallTest?a=hello&b=world' in my browser) then this
works fine.
But when I try to access this with ajax via jQuery on outside domain it
gets the error I mentioned above.
Thanks for any help you can provide.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.