CORS is a security browser issue. The browser is preventing a cross site
scripting attack. You need to look at sending the correct headers that tell
your browser client that all is ok.

Please google CORS and read up on the issue.

On Wed, Feb 25, 2015 at 7:28 AM, Dave Sag <[email protected]> wrote:

> Here's how I am doing it (business specific logic trimmed out)
>
> var app = require('express')()
> var http = require('http').Server(app)
> var io = require('socket.io')(http)
> var port = process.env.PORT || 8000
>
> http.listen(port, function () {
>   console.log("Server listening on port " + port)
> })
>
> io.on('connection', function (socket) {
>   console.log("Connection opened")
>
>   socket.on('disconnect', function () {
>     console.log("Socket disconnected")
>   })
>
>   socket.on('my-event', function(data){
>     console.log("got data for my-event", data)
>   })
> })
>
> hope that helps
>
> d
>
> On Wednesday, 25 February 2015 03:32:46 UTC+11, Julien Lereverend wrote:
>>
>> Hello everybody,
>>
>> When i try to access Node JS with socket.io and https i have an error.
>>
>> My app
>> var https = require('https');
>> var fs = require('fs');
>> var elasticsearch = require('elasticsearch');
>>
>> var client = new elasticsearch.Client({
>>     host: 'localhost:9200'/*,
>>     log: 'trace'*/
>> });
>>
>> var options = {
>>   key: fs.readFileSync('key.pem'),
>>   cert: fs.readFileSync('cert.pem')
>> };
>>
>> var serverhttps = https.createServer(options, function (req, res) {});
>>
>> var io = require('socket.io').listen(serverhttp);
>> io.set('origins', '*:*');
>>
>> // Quand on client se connecte
>> io.sockets.on('connection', function (socket) {
>>     console.log('Connecte');
>>
>>     // Quand on reçoit un appel search
>>     socket.on('search', function (obj) {
>>         client.search(obj.searchQuery, function (error, reponse) {
>>             socket.emit('returnResultElasticsearch', {'searchType':obj.
>> searchType, 'searchResult':reponse});
>>         });
>>     });
>>
>>     // Quand on reçoit un appel suggest
>>     socket.on('suggest', function (obj) {
>>         client.suggest(obj.suggestQuery, function (error, reponse) {
>>             socket.emit('returnResultAutoCompletion', {'suggestType':obj.
>> suggestType, 'suggestResult':reponse});
>>         });
>>     });
>> });
>>
>> serverhttp.listen(8080, "0.0.0.0");
>>
>>
>>
>> My client
>> var socket = io.connect('https://my.domain:8080', {
>>     'reconnect':false
>> });
>>
>>
>> I have the message error
>> https://my.domain:8080/socket.io/?EIO=3&transport=polling&t=
>> 1424795460423-0
>> A multi-origin request was blocked: the policy "Same origin" does not
>> allow to see remote resource located in https://my.domain:8080/
>> socket.io/?EIO=3&transport=polling&t=1424795460423-0
>> <https://api.imgur.com/3/upload>. this an be fixed by moving the
>> resource on the samin domain or by enabling CORS.
>>
>> Can you help me please ?
>>
>  --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/0ab19fd4-4903-481f-9ff2-18fbf639c983%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/0ab19fd4-4903-481f-9ff2-18fbf639c983%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAFszCkOWw793svxCBUKZ%3Dw9fuOs40%2BSEg24iUrVOQ6wwfKgDfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to