From 461211ad29966fc5505d9e2fb6485884983d99af Mon Sep 17 00:00:00 2001 From: Geno Date: Fri, 27 Nov 2020 12:53:00 +0100 Subject: [PATCH] add cors --- templates/conf.d/00-default.toml | 5 +++++ templates/conf.d/70-easy-proxy.toml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/conf.d/00-default.toml b/templates/conf.d/00-default.toml index e93cb41..42955f4 100644 --- a/templates/conf.d/00-default.toml +++ b/templates/conf.d/00-default.toml @@ -1,3 +1,8 @@ [http.middlewares.httpsRedirect.redirectScheme] scheme = "https" permanent = true +[http.middlewares.corsAll.headers] + AccessControlAllowMethods= ["GET", "OPTIONS", "PUT"] + AccessControlAllowOrigin = "*" + AccessControlMaxAge = 100 + AddVaryHeader = true diff --git a/templates/conf.d/70-easy-proxy.toml b/templates/conf.d/70-easy-proxy.toml index 02bc1a4..10953b7 100644 --- a/templates/conf.d/70-easy-proxy.toml +++ b/templates/conf.d/70-easy-proxy.toml @@ -20,9 +20,9 @@ [http.routers.{{r.name}}] rule = "{{ r.rule }}" {% if r.tls %} - entryPoints = ["websecure"] + entryPoints = ["websecure"{% if r.corsAll %}, "corsAll"{% endif %}] {% else %} - entryPoints = ["web"] + entryPoints = ["web"{% if r.corsAll %}, "corsAll"{% endif %}] {% endif %} service = "{{r.name}}@file" {% if r.tls %}