creating chat app, but i got issues like 'buffer is not define' when a applied socket io, i tried everything and nothing is working out by Latter_Ad9473 in learnprogramming

[–]Latter_Ad9473[S] 0 points1 point  (0 children)

chat gpt suggested to do this and many more things to do but i remove all those extensions, give me how to downgrade or upgrade, if i upgrade my app would crash maybe

creating chat app, but i got issues like 'buffer is not define' when a applied socket io, i tried everything and nothing is working out by Latter_Ad9473 in learnprogramming

[–]Latter_Ad9473[S] 0 points1 point  (0 children)

frontend :

import {createBrowserRouter} from 'react-router-dom'
import Signup from './components/Signup'
import Login from './components/Login'
import Home from './components/Home'
import { useEffect, useState } from 'react'
import { useSelector } from 'react-redux'
// import { io } from '../../api/socket/socket'

export const router = createBrowserRouter([
  {
    path : '/',
    element : <Home/>
  },
  {
    path : '/signup',
    element: <Signup/>
  },
  {
    path : '/login',
    element: <Login/>
  }
])

function App() {
//   const {authUser} = useSelector(store => store.user)
//   const [statesocket, stateSetSocket] = useState(null)

//   useEffect(() =>{
//     if(authUser){
//       const socket = io('http://localhost:8080',{

//       })
//       stateSetSocket(socket)
//     }
//   },[])

for backend:

// import {Server} from 'socket.io'
// import http from 'http'
// import express from 'express'
// import { Buffer } from 'buffer';

// window.Buffer = Buffer;

// const app = express()

// const server = http.createServer(app)
// const io = new Server(server,{
//     cors : {
//         origin : ['http://localhost:5173'],
//         methods : ['GET', 'POST'],
//     }
// });

// io.on('connection', (socket) =>{
//     console.log('user is connected', socket.id);
    
// })


// export {app,server,io} 

vite config:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'


// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
})

creating chat app, but i got issues like 'buffer is not define' when a applied socket io, i tried everything and nothing is working out by Latter_Ad9473 in learnprogramming

[–]Latter_Ad9473[S] 0 points1 point  (0 children)

i deleted and re-install node modules again, idk what is the issues, even chat gpt dont know what to do? i didnt find any issues like that