Respond to OPTIONS in rpc

This commit is contained in:
Kevin F 2023-01-04 00:52:15 -06:00
parent 474ef21163
commit 7895442b51
1 changed files with 6 additions and 0 deletions

View File

@ -60,6 +60,12 @@ class OnionrRPC(object):
@cherrypy.expose
def rpc(self):
# Dispatcher is dictionary {<method_name>: callable}
if cherrypy.request.method == 'OPTIONS':
cherrypy.response.headers['Access-Control-Allow-Origin'] = '*'
cherrypy.response.headers['Access-Control-Allow-Methods'] = 'POST'
return ''
data = cherrypy.request.body.read().decode('utf-8')
response = JSONRPCResponseManager.handle(data, dispatcher)