Socket.io need url define in page.ts, not in module.ts ionic-v4

in app.module.ts

import { SocketIoModule, SocketIoConfig } from 'ng-socket-io';
........
const config: SocketIoConfig = { url: 'http://localhost:3001', options: {} };
........
imports: [
    SocketIoModule.forRoot(config)
  ]

but i want to define url in chat.page.ts

I think you’re going to have to declare a subclass of Socket as described in the “Using multiple sockets with different end points” section of the docs and then instantiate it manually using new, passing the URL into the constructor. Normally I really hate doing this, and at a glance this looks like a big design flaw in this library. There are several open issues against it asking for roughly the same thing you are. You may be able to get it managed under DI using an InjectionToken, but I’m not sure it would be worth the effort.

yes many issues and effort. another issue is

(window as any).global = window;

what about this?

Obviously this is up to you, but when I see things like:

…that’s when I get off the bus and look for another alternative that isn’t going to cause me an eternal maintenance migraine.