test_proxy_debug.ps1 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Debug proxy issue - test directly vs through proxy
  2. $body = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'
  3. $loginResp = Invoke-WebRequest -Uri 'http://localhost:8006/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
  4. $token = ($loginResp.Content | ConvertFrom-Json).token
  5. Write-Host "Direct login OK, token length: $($token.Length)"
  6. # Test HIS direct vs proxy
  7. $testPaths = @(
  8. '/his/healthTongue/list',
  9. '/his/healthRecord/list',
  10. '/course/courseDomainName/list',
  11. '/billing/wallet/list',
  12. '/transfer/fsTransfer/list',
  13. '/his/prescription/list'
  14. )
  15. foreach ($path in $testPaths) {
  16. # Direct
  17. try {
  18. $r = Invoke-WebRequest -Uri "http://localhost:8006$path" -Method Get -Headers @{Authorization="Bearer $token"} -UseBasicParsing -TimeoutSec 5
  19. $content = $r.Content | ConvertFrom-Json
  20. Write-Host "DIRECT $path => code=$($content.code)"
  21. } catch {
  22. Write-Host "DIRECT $path => ERROR: $($_.Exception.Message.Substring(0,50))"
  23. }
  24. # Through proxy
  25. try {
  26. $r = Invoke-WebRequest -Uri "http://localhost:80/prod-api$path" -Method Get -Headers @{Authorization="Bearer $token"} -UseBasicParsing -TimeoutSec 5
  27. $content = $r.Content | ConvertFrom-Json
  28. Write-Host "PROXY $path => code=$($content.code)"
  29. } catch {
  30. $statusCode = 0
  31. if ($_.Exception.Response) { $statusCode = [int]$_.Exception.Response.StatusCode }
  32. Write-Host "PROXY $path => $statusCode ERROR: $($_.Exception.Message.Substring(0,[Math]::Min(50,$_.Exception.Message.Length)))"
  33. }
  34. Write-Host ""
  35. }