diff --git a/plugins/clnrest/utilities/rpc_plugin.py b/plugins/clnrest/utilities/rpc_plugin.py index c376ded2e..a2473a51c 100644 --- a/plugins/clnrest/utilities/rpc_plugin.py +++ b/plugins/clnrest/utilities/rpc_plugin.py @@ -7,3 +7,4 @@ plugin.add_option(name="rest-certs", default=os.getcwd(), description="Path for plugin.add_option(name="rest-protocol", default="https", description="REST server protocol", opt_type="string", deprecated=False) plugin.add_option(name="rest-host", default="127.0.0.1", description="REST server host", opt_type="string", deprecated=False) plugin.add_option(name="rest-port", default=None, description="REST server port to listen", opt_type="int", deprecated=False) +plugin.add_option(name="rest-cors-origins", default="*", description="Cross origin resource sharing origins", opt_type="string", deprecated=False, multi=True) diff --git a/plugins/clnrest/utilities/shared.py b/plugins/clnrest/utilities/shared.py index 9f139a72c..c9adb0e55 100644 --- a/plugins/clnrest/utilities/shared.py +++ b/plugins/clnrest/utilities/shared.py @@ -2,17 +2,22 @@ import json5 import re import json -CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT = "", "", "", "" +CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CORS_ORIGINS = "", "", "", "", [] def set_config(options): if 'rest-port' not in options: return "`rest-port` option is not configured" - global CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT + global CERTS_PATH, REST_PROTOCOL, REST_HOST, REST_PORT, REST_CORS_ORIGINS CERTS_PATH = str(options["rest-certs"]) REST_PROTOCOL = str(options["rest-protocol"]) REST_HOST = str(options["rest-host"]) REST_PORT = int(options["rest-port"]) + cors_origins = options["rest-cors-origins"] + REST_CORS_ORIGINS.clear() + for origin in cors_origins: + REST_CORS_ORIGINS.append(str(origin)) + return None