Skip to content

Commit 2fc92d7

Browse files
authored
Merge pull request #52 from devilbox/release-1.0.10
Streamline CORS headers
2 parents 98cdbd3 + e313907 commit 2fc92d7

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

bin/vhost-gen

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ if os.environ.get("MYPY_CHECK", False):
2929
# --------------------------------------------------------------------------------------------------
3030
APPNAME = "vhost-gen"
3131
APPREPO = "https://github.com/devilbox/vhost-gen"
32-
VERSION = "1.0.9"
33-
RELDATE = "2022-12-27"
32+
VERSION = "1.0.10"
33+
RELDATE = "2022-12-31"
3434

3535
# Default paths
3636
CONFIG_PATH = "/etc/vhost-gen/conf.yml"

etc/templates/apache22.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,16 @@ features:
181181
Allow from all
182182
</Location>
183183
184+
# https://stackoverflow.com/a/42558499
185+
# https://fetch.spec.whatwg.org/#forbidden-header-name
184186
xdomain_request: |
185187
# Allow cross domain request from these hosts
186188
SetEnvIf Origin "__REGEX__" AccessControlAllowOrigin=$0
187-
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
188-
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
189+
Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
190+
Header always set Access-Control-Allow-Methods "HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS"
191+
Header always set Access-Control-Allow-Headers "Accept, Authorization, Content-Security-Policy, Content-Type, Location, Origin, X-Requested-With"
192+
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
189193
Header always set Access-Control-Max-Age "0"
190-
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
191194
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
192195
RewriteEngine On
193196
RewriteCond %{REQUEST_METHOD} OPTIONS

etc/templates/apache24.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,16 @@ features:
206206
Require all granted
207207
</Location>
208208
209+
# https://stackoverflow.com/a/42558499
210+
# https://fetch.spec.whatwg.org/#forbidden-header-name
209211
xdomain_request: |
210212
# Allow cross domain request from these hosts
211213
SetEnvIf Origin "__REGEX__" AccessControlAllowOrigin=$0
212-
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
213-
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
214+
Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
215+
Header always set Access-Control-Allow-Methods "HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS"
216+
Header always set Access-Control-Allow-Headers "Accept, Authorization, Content-Security-Policy, Content-Type, Location, Origin, X-Requested-With"
217+
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
214218
Header always set Access-Control-Max-Age "0"
215-
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
216219
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
217220
RewriteEngine On
218221
RewriteCond %{REQUEST_METHOD} OPTIONS

etc/templates/nginx.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ features:
166166
167167
xdomain_request: |
168168
# Allow cross domain request from these hosts
169+
# https://fetch.spec.whatwg.org/#forbidden-header-name
169170
if ( $http_origin ~* (__REGEX__) ) {
170-
add_header "Access-Control-Allow-Origin" "$http_origin";
171-
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
172-
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
173-
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
171+
add_header "Access-Control-Allow-Origin" "$http_origin";
172+
add_header 'Access-Control-Allow-Methods' 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS';
173+
add_header 'Access-Control-Allow-Headers' 'Accept, Authorization, Content-Security-Policy, Content-Type, Location, Origin, X-Requested-With';
174+
add_header 'Access-Control-Expose-Headers' 'Content-Security-Policy, Location';
174175
add_header 'Access-Control-Max-Age' 0;
175176
return 200;
176177
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="vhost-gen",
9-
version="1.0.9",
9+
version="1.0.10",
1010
description="Configurable vHost generator for Apache 2.2, Apache 2.4 and Nginx.",
1111
license="MIT",
1212
long_description=long_description,

0 commit comments

Comments
 (0)