@@ -58,15 +58,21 @@ server {
5858 }
5959 }
6060
61- # Product images
62- location /product_images {
63- alias /var/www/posdic/backend/product_images;
61+ # Product images - must come before static files regex
62+ location /product_images/ {
63+ alias /var/www/posdic/backend/product_images/ ;
6464 expires 7d;
6565 add_header Cache-Control "public";
66+
67+ # CORS headers for mobile app support
68+ add_header Access-Control-Allow-Origin $http_origin always;
69+ add_header Access-Control-Allow-Methods "GET, OPTIONS" always;
70+ add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With" always;
71+ add_header Access-Control-Allow-Credentials "true" always;
6672 }
6773
68- # Static files with cache
69- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
74+ # Static files with cache (excluding product_images to avoid conflict)
75+ location ~* ^/(?!product_images/).* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
7076 expires 30d;
7177 add_header Cache-Control "public";
7278 }
@@ -112,7 +118,7 @@ server {
112118 gzip_vary on;
113119 gzip_min_length 1024;
114120 gzip_comp_level 6;
115- gzip_types text/plain text/css text/xml text/javascript
121+ gzip_types text/plain text/css text/xml text/javascript
116122 application/json application/javascript application/xml+rss;
117123
118124 # API Backend
@@ -126,29 +132,35 @@ server {
126132 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
127133 proxy_set_header X-Forwarded-Proto $scheme;
128134 proxy_cache_bypass $http_upgrade;
129-
135+
130136 # CORS headers for mobile app support (development)
131137 add_header Access-Control-Allow-Origin $http_origin always;
132138 add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, PATCH, OPTIONS" always;
133139 add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With" always;
134140 add_header Access-Control-Allow-Credentials "true" always;
135141 add_header Access-Control-Max-Age 3600 always;
136-
142+
137143 # Handle preflight OPTIONS requests
138144 if ($request_method = 'OPTIONS') {
139145 return 204;
140146 }
141147 }
142148
143- # Product images
144- location /product_images {
145- alias /var/www/posdic/backend/product_images;
149+ # Product images - must come before static files regex
150+ location /product_images/ {
151+ alias /var/www/posdic/backend/product_images/ ;
146152 expires 7d;
147153 add_header Cache-Control "public";
154+
155+ # CORS headers for mobile app support
156+ add_header Access-Control-Allow-Origin $http_origin always;
157+ add_header Access-Control-Allow-Methods "GET, OPTIONS" always;
158+ add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With" always;
159+ add_header Access-Control-Allow-Credentials "true" always;
148160 }
149161
150- # Static files with cache
151- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
162+ # Static files with cache (excluding product_images to avoid conflict)
163+ location ~* ^/(?!product_images/).* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
152164 expires 30d;
153165 add_header Cache-Control "public";
154166 }
0 commit comments