Skip to content

Commit a7013c5

Browse files
WZWrenDistractedCat
authored andcommitted
Add collab fix to next config
Cherry pick fix
1 parent f83113e commit a7013c5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

peerprep/components/questionpage/CollabEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export default function CollabEditor({ question, roomID, authToken }: Props) {
7777

7878
console.log("Yep");
7979

80-
const newSocket = new WebSocket(`${process.env.NEXT_PUBLIC_COLLAB}/ws?roomID=${roomID}`);
81-
80+
const newSocket = new WebSocket(`/api/proxy?roomID=${roomID}`);
81+
8282
newSocket.onopen = () => {
8383
console.log("WebSocket connection established");
8484
setconnected(true);

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)