Open CPlusPatch opened 1 year ago
Hello, I am using Next.js to make an app and I am trying to connect to my account using WebSocket.
Here is my code (frontend React)
export const HomeFeed = () => { const [posts, setPosts] = useState<Entity.Status[]>([]); useEffect(() => { const client = generator( "pleroma", "wss://fedi.cpluspatch.com", process.env.NEXT_PUBLIC_ACCESS_TOKEN, ); const stream: WebSocketInterface = client.userSocket() stream.on("connect", () => { console.log("connect"); }); stream.on("parser-error", (err: Error) => { console.error(err); }); }, []); return ... };
Here is my Webpack config:
webpack: (config) => { config.resolve.fallback = { net: false, tls: false, dns: false, zlib: false, fs: false, stream: require.resolve('stream-browserify'), events: require.resolve('events'), buffer: require.resolve('buffer'), url: require.resolve('url'), http: require.resolve('stream-http'), https: require.resolve('https-browserify'), crypto: require.resolve('crypto-browserify'), querystring: require.resolve('querystring-es3'), os: require.resolve('os-browserify/browser'), assert: require.resolve('assert') } return config; }
The error I am getting is "TypeError: invalid 'instanceof' operand URL" at line const stream: WebSocketInterface = client.userSocket()
const stream: WebSocketInterface = client.userSocket()
Here is my stack trace: https://pastebin.com/v5hkQN0Y
Am I doing something wrong?
Hmm, I'm not sure. Your code seems good.
This has happened several times with different projects
Hello, I am using Next.js to make an app and I am trying to connect to my account using WebSocket.
Here is my code (frontend React)
Here is my Webpack config:
The error I am getting is "TypeError: invalid 'instanceof' operand URL" at line
const stream: WebSocketInterface = client.userSocket()
Here is my stack trace: https://pastebin.com/v5hkQN0Y
Am I doing something wrong?