Fix redirect loop and login redirect for /ppt-tool deployment

- Add basePath/assetPrefix to next.config.mjs (was only patched on server)
- Fix AuthGuard to use router.push('/login') instead of window.location.href
  (window.location ignores Next.js basePath, sent users to /login not /ppt-tool/login)
- Remove deploy.sh Step 10 deckforge.conf creation — DeckForge rules are now
  merged into optical-dev.oliver.solutions.conf alongside OliVAS config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-03-19 21:57:45 +00:00
parent 8960267c3c
commit 3077159da3
3 changed files with 14 additions and 18 deletions

View file

@ -243,26 +243,21 @@ docker compose -f docker-compose.yml -f docker-compose.prod.yml \
# ─────────────────────────────────────────────────────────────────────────────
info "Step 10: Configuring Apache..."
APACHE_CONF_SRC="$SCRIPT_DIR/apache/deckforge.conf"
APACHE_CONF_DST="/etc/apache2/sites-available/deckforge.conf"
# DeckForge rules are merged into optical-dev.oliver.solutions.conf (managed by OliVAS team).
# We only need to ensure deckforge.conf is disabled (if it still exists from a prior deploy)
# and reload Apache.
# Substitute actual ports into the template
sed \
-e "s/API_PORT/${API_PORT}/g" \
-e "s/WEB_PORT/${WEB_PORT}/g" \
"$APACHE_CONF_SRC" | sudo tee "$APACHE_CONF_DST" > /dev/null
if [[ -L /etc/apache2/sites-enabled/deckforge.conf ]]; then
sudo a2dissite deckforge.conf -q || true
info " Disabled legacy deckforge.conf"
fi
info " Written $APACHE_CONF_DST"
# Disable default site on first install
# Disable default site if present
if [[ -L /etc/apache2/sites-enabled/000-default.conf ]]; then
sudo a2dissite 000-default.conf -q || true
info " Disabled 000-default.conf"
fi
sudo a2ensite deckforge.conf -q
info " Enabled deckforge.conf"
# Health check page — Google LB requires GET / to return 200
sudo mkdir -p /var/www/html
sudo tee /var/www/html/index.html > /dev/null << 'EOF'
@ -277,7 +272,7 @@ if sudo apache2ctl configtest 2>&1 | grep -q "Syntax OK"; then
sudo systemctl reload apache2
info " Apache reloaded"
else
error "Apache config test failed — check $APACHE_CONF_DST"
error "Apache config test failed"
sudo apache2ctl configtest
exit 1
fi

View file

@ -4,7 +4,7 @@ import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { fetchCurrentUser, checkDevMode } from '@/store/slices/authSlice';
import { RootState, AppDispatch } from '@/store/store';
import { usePathname } from 'next/navigation';
import { usePathname, useRouter } from 'next/navigation';
const PUBLIC_PATHS = ['/login'];
@ -14,6 +14,7 @@ export function AuthGuard({ children }: { children: React.ReactNode }) {
(state: RootState) => state.auth
);
const pathname = usePathname();
const router = useRouter();
useEffect(() => {
dispatch(fetchCurrentUser());
@ -53,9 +54,7 @@ export function AuthGuard({ children }: { children: React.ReactNode }) {
}
if (!isAuthenticated) {
if (typeof window !== 'undefined') {
window.location.href = '/login';
}
router.push('/login');
return null;
}

View file

@ -2,6 +2,8 @@
const API_URL = process.env.API_INTERNAL_URL || 'http://localhost:8000';
const nextConfig = {
basePath: "/ppt-tool",
assetPrefix: "/ppt-tool",
reactStrictMode: false,
distDir: ".next-build",