Socket Io Cors Errors with External Backend Implementation

Viewed 8

My backend is on node.js with socket implementation and front-end on next js. I implemented socket on the backend but difficult to integrate on the next js

below is the code of the next js

import io from 'socket.io-client';
const [socket, setSocket] = useState(null);
const newSocket = io(http://localhost:8000);
setSocket(newSocket);

but I get below error from frontend

Access to XMLHttpRequest at 'http://localhost:8000/socket.io/?EIO=4&transport=polling&t=ODaCcjb' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I added cors on backend side but still this issue

0 Answers
Related