Next.js Discord

Discord Forum

Rewrites socket still pending

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
This is my code rewrites
 async rewrites() {
    return [
      {
        source: '/api/:path*',
        destination: `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/:path*/`,
      },
    ];
  },

It works well with HTTP requests but it doesn't work with WebSocket. It's pending at ws://localhost:3000/api/v1/socket/?EIO=4&transport=websocket

 const socket = io('/', {
      path: '/api/v1/socket',
      transports: ['websocket'],
    });

3 Replies

Saltwater CrocodileOP
@gin It's still pending after adding /
 const socket = io('/', {
      path: '/api/v1/socket/',
      transports: ['websocket'],
    });