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:
@@ -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)
|
||||
|
||||
@@ -465,15 +465,21 @@ function Deploy-Frontend {
|
||||
Copy-Item -Path $sourceFe -Destination $Config.FrontendPath -Recurse -Force
|
||||
Write-Success "Frontend files deployed"
|
||||
|
||||
# Copy web.config if present in package
|
||||
$webConfig = Join-Path $SourcePath "config\web.config"
|
||||
if (Test-Path $webConfig) {
|
||||
$destConfig = Join-Path $Config.FrontendPath "web.config"
|
||||
Copy-Item -Path $webConfig -Destination $destConfig -Force
|
||||
Write-Success "web.config deployed"
|
||||
# Verify web.config was deployed (should be in frontend/ from dist/)
|
||||
$deployedWebConfig = Join-Path $Config.FrontendPath "web.config"
|
||||
if (Test-Path $deployedWebConfig) {
|
||||
Write-Success "web.config deployed successfully"
|
||||
# Verify it has correct configuration for /roa2web/ path
|
||||
$configContent = Get-Content $deployedWebConfig -Raw
|
||||
if ($configContent -match 'url="[^"]*roa2web/api') {
|
||||
Write-Success "web.config contains correct /roa2web/api proxy rules"
|
||||
} else {
|
||||
Write-Warning "web.config may not have correct /roa2web/api proxy configuration"
|
||||
}
|
||||
} else {
|
||||
Write-Warning "web.config not found in package: $webConfig"
|
||||
Write-Warning "web.config not found in deployed frontend: $deployedWebConfig"
|
||||
Write-Warning "IIS reverse proxy will not work without web.config"
|
||||
Write-Warning "Ensure 'public/web.config' exists in source and rebuild frontend"
|
||||
}
|
||||
|
||||
Write-Success "Frontend deployment completed successfully"
|
||||
|
||||
Reference in New Issue
Block a user