Clients are unable to connect to server during selenium tests
You can usually solve pre-flight errors with a change to your web.config:
<system.webServer> ...<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept, Cache-Control" /> <add name="Access-Control-Allow-Credentials" value="true" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> </customHeaders></httpProtocol></system.webServer>
Or via code in a custom handler with something like:
if (request.Headers.Contains("Origin") && request.Method.Method == "OPTIONS"){ var response = new HttpResponseMessage(); response.StatusCode = HttpStatusCode.OK; response.Headers.Add("Access-Control-Allow-Origin", "*"); response.Headers.Add("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, Authorization"); response.Headers.Add("Access-Control-Allow-Methods", "DELETE, POST, PUT, OPTIONS, GET");}
If it works you can then try refining things by e.g. changing Access-Control-Allow-Origin
to just your front-ends address.
Assuming you are using windows OS. If yes then, did you allow your application to bypass windows firewall..? ex: if you have a application running on localhost:9000, then you need to make sure windows firewall has rules to allow port 9000.
Hope, this resolves your issue.