'https://www.example.com and https://example.com socket.io connection problem

How do I get both https://example.com and https://www.example.com for endpoints to connect? socket.io connect no problem at htttps://example.com but not https://www.example.com

my server looks like

const server = http.createServer(app);
const io = socketIo(server, {
  cors: {
    origin: "https://www.example.com:3000",
    methods: ["GET", "POST"],
    allowedHeaders: ["my-custom-header"],
    credentials: true
  }});

and my client endpoint looks like this

const ENDPOINT = 'https://example.com/';


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source