4

I use Botdetect in angular 8 project and ASPNET WebApi2 Backend.

but this error

Access to XMLHttpRequest at 'http://localhost:29739/simple-captcha-endpoint.ashx?get=html&c=yourFirstCaptchaStyle' from origin 'http://localhost:4500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I use EnableCors

 config.EnableCors();
        config.EnableCors(new EnableCorsAttribute("*", "*", "*")
        {
            SupportsCredentials = true,

        });

and added botdetect.xml file

<captchaEndpoint>
 <accessControlAllowOriginHeaderEnabled>true</accessControlAllowOriginHeaderEnabled>
 <accessControlAllowOriginHeaderValue>http://localhost:4500</accessControlAllowOriginHeaderValue>
</captchaEndpoint>
Simply Ged
  • 8,250
  • 11
  • 32
  • 40

2 Answers2

0

If you work on local application, you can just install extension.

If you want a real solution you have to add a proxy config, please check this link

This happens becuase your front and back have not the same URL and port, it's a cross-domain request.

BELLIL
  • 739
  • 10
  • 23
0

Create a chrome shortcut then open properties and add --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp after "C:\Program Files\Google\Chrome\Application\chrome.exe"

Farouq
  • 1
  • 1