Base solution for your next web application
Open Closed

Chat not connecting after deploying to Azure #7574


User avatar
0
vnetonline created

When I deployed AspNetCore & Angular to Azure the Chat won't connect and throughs websocket errors


2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Please share the error message of the browser console and the log information of the application backend.

  • User Avatar
    0
    vnetonline created

    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

    1. Click CORS

    1. Check the Enable Access-Control-Allow-Credentials

    1. Click Save

    2. Now click on Configruation under the Stettings Sections in the menu

    1. Click on General Settings and turn on Websockets

    1. 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