Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
feat(webserver): add CORS for /packs endpoints
Browse files Browse the repository at this point in the history
Fixes #248
  • Loading branch information
ajgon committed Dec 12, 2020
1 parent ac93374 commit ede019d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions templates/default/appserver.apache2.passenger.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ Header always unset "X-Powered-By"
LimitRequestBody <%= @out[:limit_request_body] || '1048576' %>
KeepAliveTimeout <%= @out[:keepalive_timeout] || '15' %>

<Location "/assets/">
<LocationMatch "/(assets|packs)/">
ExpiresActive on

Header set Cache-Control "public"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, PUT, POST, DELETE"
Header set Access-Control-Expose-Headers "ETag"
Header set X-Content-Type-Options "nosniff"
</Location>
</LocationMatch>

<% if @appserver_config[:max_pool_size] -%>
PassengerMaxPoolSize <%= @appserver_config[:max_pool_size] %>
Expand Down Expand Up @@ -138,15 +138,15 @@ SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
LimitRequestBody <%= @out[:client_max_body_size] || '1048576' %>
KeepAliveTimeout <%= @out[:keepalive_timeout] || '15' %>

<Location "/assets/">
<LocationMatch "/(assets|packs)/">
ExpiresActive on

Header set Cache-Control "public"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, PUT, POST, DELETE"
Header set Access-Control-Expose-Headers "ETag"
Header set X-Content-Type-Options "nosniff"
</Location>
</LocationMatch>

<% if @appserver_config[:max_pool_size] -%>
PassengerMaxPoolSize <%= @appserver_config[:max_pool_size] %>
Expand Down
10 changes: 6 additions & 4 deletions templates/default/appserver.apache2.upstream.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Listen <%= @out[:port] %>
LimitRequestBody <%= @out[:limit_request_body] || '1048576' %>
KeepAliveTimeout <%= @out[:keepalive_timeout] || '15' %>

<Location "/assets/">
<LocationMatch "/(assets|packs)/">
ExpiresActive on

Header set Cache-Control "public"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, PUT, POST, DELETE"
Header set Access-Control-Expose-Headers "ETag"
Header set X-Content-Type-Options "nosniff"
</Location>
</LocationMatch>

RewriteEngine on

Expand All @@ -57,6 +57,7 @@ Listen <%= @out[:port] %>
RewriteRule ^/(.*)$ balancer://<%= upstream %>%{REQUEST_URI} [P,QSA,L]

ProxyPass /assets "!"
ProxyPass /packs "!"
ProxyPass / balancer://<%= upstream %>/
ProxyPassReverse / balancer://<%= upstream %>/
ProxyPreserveHost on
Expand Down Expand Up @@ -125,15 +126,15 @@ SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
LimitRequestBody <%= @out[:client_max_body_size] || '1048576' %>
KeepAliveTimeout <%= @out[:keepalive_timeout] || '15' %>

<Location "/assets/">
<LocationMatch "/(assets|packs)/">
ExpiresActive on

Header set Cache-Control "public"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, PUT, POST, DELETE"
Header set Access-Control-Expose-Headers "ETag"
Header set X-Content-Type-Options "nosniff"
</Location>
</LocationMatch>

RewriteEngine on

Expand All @@ -145,6 +146,7 @@ SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
RewriteRule ^/(.*)$ balancer://<%= upstream %>%{REQUEST_URI} [P,QSA,L]

ProxyPass /assets "!"
ProxyPass /packs "!"
ProxyPass / balancer://<%= upstream %>/
ProxyPassReverse / balancer://<%= upstream %>/
ProxyPreserveHost on
Expand Down
4 changes: 2 additions & 2 deletions templates/default/appserver.nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ server {
try_files $uri/index.html $uri/index.htm @<%= @name %>;
}

location ^~ /assets/ {
location ~* ^/(assets|packs)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
Expand Down Expand Up @@ -137,7 +137,7 @@ server {
try_files $uri/index.html $uri/index.htm @<%= @name %>;
}

location ^~ /assets/ {
location ~* ^/(assets|packs)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
Expand Down

0 comments on commit ede019d

Please sign in to comment.