Skip to content

Instantly share code, notes, and snippets.

@leandroribeiro
Created March 15, 2024 13:56
Show Gist options
  • Save leandroribeiro/a583b65b0e7f59f54b388639c390abe0 to your computer and use it in GitHub Desktop.
Save leandroribeiro/a583b65b0e7f59f54b388639c390abe0 to your computer and use it in GitHub Desktop.
Testando CORS através do PowerShell
$response = Invoke-WebRequest -Uri "https://#FILL_TARGET_HERE#" -Method Options -Headers @{
"Origin" = "https://#FILL_ORIGIN_HERE#"
"Access-Control-Request-Method" = "GET"
"Access-Control-Request-Headers" = "Authorization"
"Accept" = "application/json"
} -UseBasicParsing
$color = "Red"
$headers = $response.Headers | ConvertTo-Json
if ($headers -match "Access-Control-Allow-Origin") {
$color = "DarkGreen"
}
$formatedResponse = $response | Select-Object * -ExcludeProperty BaseResponse | ConvertTo-Json -Depth 5
Write-Host $formatedResponse -ForegroundColor $color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment