From d2b2bd0b6ca70737a96845f45edc85050250650c Mon Sep 17 00:00:00 2001 From: Rub21 Date: Wed, 13 Sep 2023 11:43:23 -0500 Subject: [PATCH] Handle preflight requests --- images/web/config/production.conf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/images/web/config/production.conf b/images/web/config/production.conf index b2ed3717..7510517a 100644 --- a/images/web/config/production.conf +++ b/images/web/config/production.conf @@ -3,13 +3,8 @@ # Tell Apache and Passenger where your app's 'public' directory is DocumentRoot /var/www/public PassengerRuby /usr/bin/ruby - - # CORS headers - Header set Access-Control-Allow-Origin "*" - Header set Access-Control-Allow-Methods "GET, POST, OPTIONS" - Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept" - RewriteEngine On + RewriteCond %{HTTP:X-Forwarded-Proto} =http # Handle preflight requests RewriteCond %{REQUEST_METHOD} OPTIONS @@ -18,23 +13,28 @@ # Avoid redirects for preflight RewriteCond %{REQUEST_METHOD} !OPTIONS - # Existing rewrites for HTTPS and www - RewriteCond %{HTTP:X-Forwarded-Proto} =http + # Development mode in case domain is localhost + # Rewrite to HTTPS RewriteCond %{HTTP_HOST} !=localhost RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] - + # Rewrite to www. [NC] is a case-insensitive match RewriteCond %{HTTP_HOST} !=localhost + # Avoid redirect staging sites RewriteCond %{HTTP_HOST} !=staging.openhistoricalmap.org RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] - # Existing rewrites for CGIMAP + # ======Redirect trafict to CGIMAP==== + # Rules to redirect to port 81 RewriteCond %{REQUEST_URI} ^/api/0\.6/map RewriteRule ^.*$ http://127.0.0.1:81%{REQUEST_URI} [P,L] + # Existing rewrites RewriteRule ^0\.6/map$ - [L,H=fcgi:127.0.0.1:81] RewriteRule ^0\.6/(nodes|ways|relations)$ - [L,H=fcgi:127.0.0.1:81] RewriteRule ^0\.6/(way|relation)/([^/]+)/full$ - [L,H=fcgi:127.0.0.1:81] + + # If no match found, fall through to port 80 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ RewriteRule ^0\.6/(node|way|relation)/([^/]+)$ - [L,H=fcgi:127.0.0.1:80]