adrianhajdin/project_chat_application

live site issue

sachin54550 opened this issue · 2 comments

Screenshot (322)
The server is working fine and there's no error showing but still messages are not sending. it's working fine on localhost though

I am having same problem but my console is showing "Access to XMLHttpRequest at 'https://ch4t-it.herokuapp.com/socket.io/?EIO=4&transport=polling&t=NR9OV9U' from origin 'https://chat-n-chat.netlify.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."

You solve that by initiating io like so

const io = socketIo(httpServer, {
  cors: {
    origin: "*",
    methods: ["GET", "POST"],
    credentials: true,
  },
});

In your index.js file.