When I deployed AspNetCore & Angular to Azure the Chat won't connect and throughs websocket errors
2 Answer(s)
-
0
Please share the error message of the browser console and the log information of the application backend.
-
0
If you are getting the following error in your console in developer tools after logging in
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Error: Failed to complete negotiation with the server: Error
Error: Failed to start the connection: Error
POST https://yourserver.azurewebsites.net/signalr-chat/negotiate?encauthtoken=wNYmO41... net::ERRFAILED
Solution:
Turn on Enable Access-Control-Allow-Credentials Turn WebSockets to on.
Explanation:
From the Azure Portal locate your App Service that is hosting your AspNetCore website
- Click CORS
- Check the Enable Access-Control-Allow-Credentials
Click Save
Now click on Configruation under the Stettings Sections in the menu
- Click on General Settings and turn on Websockets
- Now you should the chat should connect once logged in and no more errors in your console in developer tools.
Be sure to empty Cache and Hard reload your browser