Skip to content

Commit 11a31df

Browse files
authored
Merge pull request #67 from SU-CS-321-Fall-2023/fix-socket-io-links
fix socket-io connection for deployment
2 parents 402285f + 7cebe2e commit 11a31df

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

next/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
NEXT_PUBLIC_NODE_URL=http://localhost:3000/v1
1+
NEXT_PUBLIC_NODE_URL=http://localhost:3000/v1
2+
NEXT_PUBLIC_SOCKET_URL=http://localhost:3000

next/app/(routes)/chats/page.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,25 @@ export default function Page() {
4747

4848
const friends = (friends) => {
4949
if (friends.includes(user.id)) {
50-
return (<d class="mb-2 text-2xl rounded-full font-bold tracking-tight text-white-900 dark:text-white">friends</d>)
50+
return (<d className="mb-2 text-2xl rounded-full font-bold tracking-tight text-white-900 dark:text-white">friends</d>)
5151
} else {
52-
return (<d class="mb-2 text-2xl rounded-full font-bold tracking-tight text-white-900 dark:text-white">Not friends</d>)
52+
return (<d className="mb-2 text-2xl rounded-full font-bold tracking-tight text-white-900 dark:text-white">Not friends</d>)
5353
}
5454
}
5555

5656
const ContactCard = (chat) => {
5757
if (chat.receiverId.id == user.id) {
5858
return (
5959

60-
<div class="flex flex-row max-w-sm p-4 bg-green-500 border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
61-
<p class="mb-2 text-2xl font-bold tracking-tight text-white-900 dark:text-white">{chat.senderId.name} -</p>
60+
<div className="flex flex-row max-w-sm p-4 bg-green-500 border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
61+
<p className="mb-2 text-2xl font-bold tracking-tight text-white-900 dark:text-white">{chat.senderId.name} -</p>
6262
{friends(chat.senderId.friends)}
6363
</div>
6464
)
6565
} else {
6666
return (
67-
<div class="flex flex-row max-w-sm p-4 bg-green-500 border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
68-
<p class="mb-2 text-2xl font-bold tracking-tight text-white-900 dark:text-white">{chat.receiverId.name} -</p>
67+
<div className="flex flex-row max-w-sm p-4 bg-green-500 border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700">
68+
<p className="mb-2 text-2xl font-bold tracking-tight text-white-900 dark:text-white">{chat.receiverId.name} -</p>
6969
{friends(chat.receiverId.friends)}
7070
</div>
7171
)

next/app/(routes)/discover/page.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ export default function Page() {
127127
{isLoading && <Spinner />}
128128
{!isLoading && <Button onClick={handleMatch} color='blue' >Match</Button>}
129129
</div>
130-
<div class="grid grid-cols-4 gap-4">
130+
<div className="grid grid-cols-4 gap-4">
131131
{results?.map((result) => (
132-
<a key={result.id} class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
133-
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{result.name}</h5>
132+
<a key={result.id} className="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
133+
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{result.name}</h5>
134134
{result.classes.map((cls) => (
135-
<p key={cls.id} class="mb-2 text-sm font-medium text-gray-700 dark:text-gray-400">{cls.department_code} {cls.class_code}</p>
135+
<p key={cls.id} className="mb-2 text-sm font-medium text-gray-700 dark:text-gray-400">{cls.department_code} {cls.class_code}</p>
136136
))}
137137
{result.friends?.includes(user.id) ? (
138138
<>

next/app/(routes)/studygroups/[id]/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function Page(props) {
6060
<div className="flex items-center self-start rounded-xl rounded-tl bg-gray-300 py-2 px-3">
6161
<p>{message.content}</p>
6262
</div>
63-
<span class="text-sm font-normal text-gray-500 dark:text-gray-500">{message.user.name}</span>
63+
<span className="text-sm font-normal text-gray-500 dark:text-gray-500">{message.user.name}</span>
6464
</div>
6565
)
6666
}

next/app/socket/socket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { io } from "socket.io-client";
22

3-
const URL = "http://localhost:3000"
4-
export const socket = io(URL);
3+
const socketBaseUrl = process.env.NEXT_PUBLIC_SOCKET_URL
4+
export const socket = io(socketBaseUrl);

node/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ mongoose.connect(config.mongoose.url, config.mongoose.options).then(() => {
3232

3333
const io = require("socket.io")(http, {
3434
cors: {
35-
origin: "http://localhost:3001",
35+
origin: "*",
3636
},
37-
})
37+
});
3838

3939
io.on('connection', (socket) => {
4040
console.log('connected')

0 commit comments

Comments
 (0)