You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On order to use jsonrpc library as server in crossdomain communications with JavaScript client in web-page, server should implement CORS [1].
Not sure how correctly implement it, but I managed to use it with following workaround outside jsonrpc library --- handle OPTIONS request that is send by browser to check whether CORS is allowed and add allow headers in all responses:
def add_CORS_headers(request):
headers = request.responseHeaders
headers.addRawHeader('Access-Control-Allow-Origin', '*')
headers.addRawHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
# This is necessary for Firefox
headers.addRawHeader('Access-Control-Allow-Headers', 'Origin, Content-Type, Cache-Control')
class MyServer(JSON_RPC):
def render_OPTIONS(self, request):
add_CORS_headers(request)
return ""
def render(self, request):
if request.method == "OPTIONS":
return self.render_OPTIONS(request)
else:
add_CORS_headers(request)
return JSON_RPC.render(self, request)
On order to use jsonrpc library as server in crossdomain communications with JavaScript client in web-page, server should implement CORS [1].
Not sure how correctly implement it, but I managed to use it with following workaround outside jsonrpc library --- handle OPTIONS request that is send by browser to check whether CORS is allowed and add allow headers in all responses:
[1] https://secure.wikimedia.org/wikipedia/en/wiki/Cross-origin_resource_sharing
The text was updated successfully, but these errors were encountered: