mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
plugins/clnrest: Add rest-cors-origins
option for config
This commit is contained in:
parent
224a5dcbcf
commit
632e7abd05
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user