fix: IIS sub-application deployment for production

Fixes 3 critical issues preventing production deployment on Windows IIS:

1. **IIS Sub-Application Path Stripping**
   - Changed URL patterns from ^roa2web/api/(.*) to ^api/(.*)
   - IIS sub-app at /roa2web automatically strips prefix
   - Requests arrive as /api/* not /roa2web/api/*

2. **SPA Fallback Absolute Path**
   - Changed from url="/index.html" to url="index.html"
   - Absolute paths (/) refer to site root, not sub-app
   - Relative path correctly serves from sub-app

3. **MIME Type Duplicates (500 Error)**
   - Added <remove> before <mimeMap> for .js, .json, .webmanifest
   - Prevents "duplicate collection entry" errors
   - Allows override of server-level MIME types

Build Script Improvements:
- Build-ROA2WEB.ps1: Copy public/ folder to temp build dir
- Build-ROA2WEB.ps1: Added verification logging for web.config
- ROA2WEB-Console.ps1: Fixed web.config verification location

Cleanup:
- Removed outdated web.config.10.0.20.36-INTERNAL
- Removed temporary test files and docs

Tested: https://roa2web.romfast.ro/roa2web/ - login page loads successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 16:38:47 +02:00
parent 9008876b16
commit ce85e0643b
6 changed files with 95 additions and 830 deletions

View File

@@ -117,6 +117,11 @@ function Write-Warning {
Write-Host " [WARN] $Message" -ForegroundColor Yellow
}
function Write-Info {
param([string]$Message)
Write-Host " [INFO] $Message" -ForegroundColor Gray
}
function Resolve-FullPath {
param([string]$Path)
@@ -352,6 +357,26 @@ function Build-Frontend {
}
}
# Copy public/ folder (contains web.config and other static assets)
$publicSourcePath = Join-Path $projectRoot "public"
if (Test-Path $publicSourcePath) {
$publicDestPath = Join-Path $tempBuildDir "public"
Write-Step "Copying public/ folder..."
Write-Info "Source: $publicSourcePath"
Write-Info "Dest: $publicDestPath"
Copy-Item -Path $publicSourcePath -Destination $publicDestPath -Recurse -Force
Write-Success "public/ folder copied (includes web.config)"
# Verify web.config was copied
$copiedWebConfig = Join-Path $publicDestPath "web.config"
if (Test-Path $copiedWebConfig) {
Write-Success "web.config found in public/"
} else {
Write-Warning "web.config NOT found in public/ - check source"
}
} else {
Write-Warning "public/ folder not found at: $publicSourcePath"
}
# Copy shared folder to maintain relative imports (../shared/)
# For ultrathin monolith: src/ and shared/ are siblings at project root
@@ -463,6 +488,15 @@ function Build-Frontend {
$totalSize = ($distFiles | Measure-Object -Property Length -Sum).Sum / 1MB
Write-Success "Generated $(($distFiles).Count) files ($([math]::Round($totalSize, 2)) MB)"
# Verify web.config was built
$webConfigPath = Join-Path $distPath "web.config"
if (Test-Path $webConfigPath) {
Write-Success "web.config found in build output"
} else {
Write-Warning "web.config NOT found in build output: $webConfigPath"
Write-Warning "Check if public/web.config exists in source"
}
return $distPath
} finally {
Pop-Location
@@ -879,7 +913,18 @@ function New-DeploymentPackage {
$frontendDest = Join-Path $OutputPath "frontend"
New-Item -ItemType Directory -Path $frontendDest -Force | Out-Null
Write-Step "Copying Unified Frontend files (SPA)..."
Write-Info "Source: $frontendDistPath"
Write-Info "Destination: $frontendDest"
Copy-Item -Path "$frontendDistPath\*" -Destination $frontendDest -Recurse -Force
# Verify web.config was copied
$copiedWebConfig = Join-Path $frontendDest "web.config"
if (Test-Path $copiedWebConfig) {
Write-Success "web.config copied to package"
} else {
Write-Warning "web.config NOT copied to package"
}
Write-Success "Unified Frontend files copied"
# Unified Backend (includes Reports, Data Entry, Telegram modules)
@@ -901,7 +946,18 @@ function New-DeploymentPackage {
$frontendDest = Join-Path $OutputPath "frontend"
New-Item -ItemType Directory -Path $frontendDest -Force | Out-Null
Write-Step "Copying Unified Frontend files (SPA)..."
Write-Info "Source: $frontendDistPath"
Write-Info "Destination: $frontendDest"
Copy-Item -Path "$frontendDistPath\*" -Destination $frontendDest -Recurse -Force
# Verify web.config was copied
$copiedWebConfig = Join-Path $frontendDest "web.config"
if (Test-Path $copiedWebConfig) {
Write-Success "web.config copied to package"
} else {
Write-Warning "web.config NOT copied to package"
}
Write-Success "Unified Frontend files copied"
# Unified Backend (includes all modules)