Support : Where to include sslOptions when initializing SOCKET
Opened this issue · 1 comments
sanyam810 commented
I'm currently working on a WebSocket server using next-ws in a Next.js environment. I need to include SSL options (Want to include ssl certificate & key) when initializing the WebSocket server , but I'm unsure how to do this properly.
import { NextRequest, NextResponse } from 'next/server';
import WebSocket from 'ws';
type DrawLine = {
prevPoint: Point | null;
currentPoint: Point;
color: string;
x: number;
y: number;
};
const clients: Set<WebSocket> = new Set();
function SOCKET(
client: WebSocket,
request: import('http').IncomingMessage,
server: WebSocketServer,
) {
// WebSocket server logic
}
function GET(req: NextRequest, res: NextResponse) {
// Handle GET request
}
function POST(req: NextRequest, res: NextResponse) {
// Handle POST request
}
export { SOCKET, GET, POST };
I need guidance on how to properly include SSL because the connection to WS don't get established when in production environment
apteryxxyz commented
Using a custom server where you create your own WebSocketServer instance and tell Next WS to use that, you could pass additional options there.