Skip to content

Commit 61a7f67

Browse files
committed
Add collab fix to next config
1 parent 003d526 commit 61a7f67

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

peerprep/components/questionpage/CollabEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function CollabEditor({ question, roomID, authToken, matchHash }:
7878

7979
console.log("Yep");
8080

81-
const newSocket = new WebSocket(`ws://localhost:4000/ws?roomID=${roomID}`);
81+
const newSocket = new WebSocket(`/api/proxy?roomID=${roomID}`);
8282

8383
newSocket.onopen = () => {
8484
console.log("WebSocket connection established");

peerprep/next.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {}
33

4-
module.exports = nextConfig
4+
module.exports = {
5+
async rewrites() {
6+
return [
7+
{
8+
source: '/api/proxy', // client connects to api/proxy
9+
// by default we expect NEXT_PUBLIC_COLLAB to be http://collab:4000.
10+
// double check this before using this.
11+
destination: `${process.env.NEXT_PUBLIC_COLLAB}/ws`,
12+
}
13+
]
14+
}
15+
}

0 commit comments

Comments
 (0)