Realtive URL fix

This commit is contained in:
James Pattinson
2025-12-10 10:10:13 +00:00
parent 39d5c2c9e2
commit 11f7390694
4 changed files with 34 additions and 32 deletions

3
.gitignore vendored
View File

@@ -72,6 +72,9 @@ logs/
*.temp *.temp
.cache/ .cache/
# Generated config files
web/config.js
# Coverage reports # Coverage reports
htmlcov/ htmlcov/
.coverage .coverage

View File

@@ -7,7 +7,6 @@ services:
# FastAPI Backend # FastAPI Backend
api: api:
build: ./backend build: ./backend
container_name: ppr_prod_api
restart: always restart: always
environment: environment:
DB_HOST: ${DB_HOST} DB_HOST: ${DB_HOST}
@@ -56,7 +55,6 @@ services:
# Redis for caching (optional) # Redis for caching (optional)
redis: redis:
image: redis:7-alpine image: redis:7-alpine
container_name: ppr_prod_redis
restart: always restart: always
networks: networks:
- app_network - app_network
@@ -69,15 +67,11 @@ services:
# Nginx web server for public frontend # Nginx web server for public frontend
web: web:
image: nginx:alpine image: nginx:alpine
container_name: ppr_prod_web
restart: always restart: always
environment: environment:
BASE_URL: ${BASE_URL} BASE_URL: ${BASE_URL}
command: > command: >
sh -c "cp /usr/share/nginx/html/ppr.html /tmp/ppr.html.orig && sh -c "echo 'window.PPR_CONFIG = { apiBase: \"'\$BASE_URL'/api/v1\" };' > /usr/share/nginx/html/config.js &&
sed 's|__BASE_URL__|'"\$BASE_URL"'|g' /tmp/ppr.html.orig > /usr/share/nginx/html/ppr.html &&
cp /usr/share/nginx/html/index.html /tmp/index.html.orig &&
sed 's|__BASE_URL__|'"\$BASE_URL"'|g' /tmp/index.html.orig > /usr/share/nginx/html/index.html &&
nginx -g 'daemon off;'" nginx -g 'daemon off;'"
ports: ports:
- "${WEB_PORT_EXTERNAL}:80" - "${WEB_PORT_EXTERNAL}:80"

View File

@@ -49,6 +49,25 @@ services:
- private_network - private_network
- public_network - public_network
# Nginx web server for public frontend
web:
image: nginx:alpine
restart: unless-stopped
environment:
BASE_URL: ${BASE_URL}
command: >
sh -c "echo 'window.PPR_CONFIG = { apiBase: \"'\$BASE_URL'/api/v1\" };' > /usr/share/nginx/html/config.js &&
nginx -g 'daemon off;'"
ports:
- "${WEB_PORT_EXTERNAL}:80"
volumes:
- ./web:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api
networks:
- public_network
# Redis for caching (optional for now) # Redis for caching (optional for now)
redis: redis:
image: redis:7-alpine image: redis:7-alpine
@@ -57,29 +76,6 @@ services:
networks: networks:
- private_network - private_network
# Nginx web server for public frontend
web:
image: nginx:alpine
container_name: ppr_nextgen_web
restart: unless-stopped
environment:
BASE_URL: ${BASE_URL}
command: >
sh -c "sed 's|__BASE_URL__|'"\$BASE_URL"'|g' /usr/share/nginx/html/ppr.html > /tmp/ppr.html &&
mv /tmp/ppr.html /usr/share/nginx/html/ppr.html &&
sed 's|__BASE_URL__|'"\$BASE_URL"'|g' /usr/share/nginx/html/index.html > /tmp/index.html &&
mv /tmp/index.html /usr/share/nginx/html/index.html &&
nginx -g 'daemon off;'"
ports:
- "${WEB_PORT_EXTERNAL}:80" # Public web interface
volumes:
- ./web:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- api
networks:
- public_network
# phpMyAdmin for database management # phpMyAdmin for database management
phpmyadmin: phpmyadmin:
image: phpmyadmin/phpmyadmin image: phpmyadmin/phpmyadmin

View File

@@ -441,9 +441,18 @@
<!-- Success Notification --> <!-- Success Notification -->
<div id="notification" class="notification"></div> <div id="notification" class="notification"></div>
<script src="/config.js"></script>
<script> <script>
// API base URL for iframe embedding // API base URL for iframe embedding - loaded from config.js or fallback
const API_BASE = 'https://ppr.swansea-airport.wales/api/v1'; console.log('=== PPR Config Debug ===');
console.log('window.PPR_CONFIG:', window.PPR_CONFIG);
console.log('window.PPR_CONFIG.apiBase:', window.PPR_CONFIG?.apiBase);
const API_BASE = (window.PPR_CONFIG && window.PPR_CONFIG.apiBase) || '/api/v1';
console.log('Final API_BASE:', API_BASE);
console.log('Source:', window.PPR_CONFIG?.apiBase ? 'config.js' : 'fallback');
console.log('=======================');
// Iframe resizing functionality // Iframe resizing functionality
function sendHeightToParent() { function sendHeightToParent() {