Home > database >  Socket.io and heroku CORS problem after deployment
Socket.io and heroku CORS problem after deployment

Time:11-15

I set up my socket.io server on heroku but I have problem with getting data from it to my app. I get cors error:

enter image description here

My app is hosted on gh-pages. Here is how my socket.io setup looks like:

const io = require("socket.io")(port, {
  cors: {
    origin: "https://name.github.io/",
    methods: ["GET"],
  },
});

What should I put in origin, should it be gh-pages link or heroku app link? How can I fix that?

This is how my request looks like:

enter image description here

I tried putting https://name.github.io/ or https://name.herokuapp.com/, to origin property but none of this worked

CodePudding user response:

For anyone having the same problem - I just removed / after url in origin and it worked :)

CodePudding user response:

You should pass { cors: true, origin: <your-client-url> } as config option.

  • Related