access apps in Heroku giving error

Asked

Viewed 637 times

0

well guys I’m trying to install an apps in Heroku but I’m not getting to visualize the status of my apps my apps is a server in Node.js and socket.io in Heroku there is the option of deploying by the site that connects in git hub until there quiet but when I type the ip of the Heroku which I believe to be the address of the app page followed by the server port that is listening on port 8000 does not return me anything.

that’s the one:

https://serverjs.herokuapp.com/

it would be a remote connection my client stays at home and my server stays in Heroku but I can’t establish connection and I don’t know if it is working because not only has some archival there.

if you want to take a look at my server in git hub by the following link and tell me what is wrong.

https://github.com/ktinho456/server

when I try to put this on my client who’s in my house from that mistake:

Blocked cross-origin request: Same Origin Policy (Same Origin Policy) prevents reading the remote resource at https://serverjs.herokuapp.com:8000/socket.io/1/? t=1434420923284. (Reason: CORS request failed).

is that my client has to be on the same server machine ?

  • 1

    I think you need to activate CORS, take a look here: https://gist.github.com/codeshrew/8926379#file-Cors-options-Node-js

  • yes but the page that Voce indicated me has some codes, what I do with these codes create a js and send to Heroku or deploy in my server.js ?

1 answer

1


Try adding the module to your Node.js server Cors. And try to add it this way:

var express = require('express'),
    cors = require('cors'),
    app = express();

app.use(cors());

//rotas abaixo

In case it still doesn’t work, configure the Cors in this way:

var express = require('express'),
    cors = require('cors'),
    app = express();


var corsOptions = {
    origin: '*'
};
app.use(cors(corsOptions));

//rotas abaixo
  • How would you focus with the added Cors? I tried it here and it didn’t work the file is in the same git hub as the link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.