Last active
          December 24, 2021 00:11 
        
      - 
      
- 
        Save Ntropish/c1caf297940e98d40be0220a8f26c5b0 to your computer and use it in GitHub Desktop. 
    Remix with Socket.io Recipe
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // This approach uses: | |
| // - Remix's Express Adapter | |
| // - An external Socket.io server on port 3050 | |
| // - http-proxy-middleware | |
| // | |
| // install http-proxy-middleware and apply these lines to `server/index.js`: | |
| // | |
| const { createProxyMiddleware } = require("http-proxy-middleware"); | |
| // Add the middleware before remix's catch-all '*' route | |
| app.use( | |
| "/socket.io", | |
| createProxyMiddleware({ | |
| target: "ws://localhost:3050", | |
| ws: true, | |
| }) | |
| ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment