Skip to content

Commit 1e5d3d0

Browse files
committed
feat: enhance deployment configuration with SSL support and CORS settings; update API base URL handling for HTTPS
1 parent 5c8fe45 commit 1e5d3d0

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,48 @@ jobs:
185185
export ORACLE_EXTERNAL_HOSTNAME=${{ secrets.ORACLE_VM_IP }}
186186
export DOCKER_REGISTRY=${{ secrets.OCI_REGISTRY }}
187187
docker-compose pull || exit 1
188-
docker-compose up -d || exit 1
188+
docker-compose up -d || exit 1 server {
189+
listen 443 ssl;
190+
server_name _;
191+
192+
ssl_certificate /etc/nginx/ssl/nginx.crt;
193+
ssl_certificate_key /etc/nginx/ssl/nginx.key;
194+
195+
# Enable detailed logging
196+
access_log /var/log/nginx/music-analytics-access.log;
197+
error_log /var/log/nginx/music-analytics-error.log;
198+
199+
location / {
200+
# CORS headers inside location block
201+
add_header 'Access-Control-Allow-Origin' 'https://musicanalytics.netlify.app' always;
202+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
203+
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization' always;
204+
205+
# Proxy settings
206+
proxy_pass http://localhost:8080;
207+
proxy_set_header Host $host;
208+
proxy_set_header X-Real-IP $remote_addr;
209+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
210+
proxy_set_header X-Forwarded-Proto $scheme;
211+
212+
# Handle OPTIONS requests
213+
if ($request_method = 'OPTIONS') {
214+
add_header 'Access-Control-Allow-Origin' 'https://musicanalytics.netlify.app' always;
215+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
216+
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization' always;
217+
add_header 'Access-Control-Max-Age' 1728000;
218+
add_header 'Content-Type' 'text/plain charset=UTF-8';
219+
add_header 'Content-Length' 0;
220+
return 204;
221+
}
222+
}
223+
}
224+
225+
server {
226+
listen 80;
227+
server_name _;
228+
return 301 https://$host$request_uri;
229+
}
189230
docker logout ${{ secrets.OCI_REGISTRY }}
190231
echo "Deployment completed successfully"
191232
EOF

frontend/src/api.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import axios from 'axios';
22

3-
// Get the API base URL from environment variables
4-
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || window.location.origin.replace(/:\d+$/, ':8080');
3+
// Ensure HTTPS is used
4+
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL
5+
? `https://${process.env.REACT_APP_API_BASE_URL.replace('https://', '')}`
6+
: window.location.origin.replace(/:\d+$/, ':8080');
57

68
const api = axios.create({
79
baseURL: API_BASE_URL,
810
headers: {
911
'Content-Type': 'application/json',
1012
},
11-
timeout: 60000, // 60 second timeout
13+
timeout: 60000,
14+
// Add this to handle self-signed certificate
15+
httpsAgent: new (require('https').Agent)({
16+
rejectUnauthorized: false
17+
})
1218
});
1319

1420
export default api;

0 commit comments

Comments
 (0)