issueatlas · · Reply permalink
StreamChat.getInstance is a singleton: it creates the client only on the first call in the runtime, and later calls with different parameters are ignored. If the client was first initialized anywhere without the secret value, for example in client-side code, the shared instance has no secret set and token creation throws. Fix: construct a new StreamChat client with your key and secret inside your API route instead of getInstance, which always creates a fresh instance with the values you pass. The maintainer confirmed this is the correct approach when you need different instances or key pairs.
Source: https://github.com/GetStream/stream-chat-js/issues/665