Friday 19 May 2017

Azure Web App Websockets CORS: Access-Control-Allow-Origin

I'm developing an API (using Node.js) and use Socket.io with Express, I been presented some errors with CORS, I resolved with Express and Socket.io 2.0 in localhost, this worked with *.azurewebsites.net but anymore works.

Testing for Express (see console): http://crawlerbackend.azurewebsites.net/test_cors_express_azure.html

Testing for Socket.io (see console): http://crawlerbackend.azurewebsites.net/test_cors_socketio_azure.html

But I need expose my Socket.io API to everybody because my clients requiere it, and tested the same files in Heroku:

Testing for Express (see console): https://testcrawlersite.herokuapp.com/test_cors_express_azure.html

Testing for Socket.io (see console): https://testcrawlersite.herokuapp.com/test_cors_socketio_azure.html

I follow best Express and Socket.io practices according with their documentation. I have an unique conclusion, I need a configuration in IISNode? or in portal? different as the option "CORS" (is set with *.. this is a fake configuration??).fake configuration?

This is the error:

XMLHttpRequest cannot load https://crawlerbackend.azurewebsites.net/socket.io/?EIO=3&transport=polling&t=LmW1TfL. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://testcrawlersite.herokuapp.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.



via Cami Rodriguez

No comments:

Post a Comment