Created
March 15, 2024 13:56
-
-
Save leandroribeiro/a583b65b0e7f59f54b388639c390abe0 to your computer and use it in GitHub Desktop.
Testando CORS através do PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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