Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-nagaraj committed Sep 1, 2024
1 parent 8583450 commit 7b00542
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
run: |
docker buildx build --platform linux/amd64 \
--tag ${{ secrets.ECR_SERVER_REPO_URI }}:latest \
--build-arg PORT=5000 \
--build-arg MONGO_URI=${{ secrets.MONGO_URI }} \
--build-arg JWT_SECRET=${{ secrets.JWT_SECRET }} \
--file ./server/Dockerfile \
./server --push
Expand Down Expand Up @@ -68,5 +71,5 @@ jobs:
docker stop server-app || true
docker rm server-app || true
docker run -d --name server-app -p 4000:4000 ${{ secrets.ECR_SERVER_REPO_URI }}:latest
docker run -d --name server-app -p 5000:5000 ${{ secrets.ECR_SERVER_REPO_URI }}:latest
EOF
27 changes: 14 additions & 13 deletions client/src/pages/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ const Chat = () => {

const fetchChatContext = async (id) => {
setIsLoading(true);
// axios.get(`https://picsum.photos/200`).then((res) => {
// setImage(res.request.responseURL);
// });
// axios
// .get("https://api.api-ninjas.com/v1/facts", {
// headers: {
// "X-Api-Key": `${import.meta.env.VITE_API_NINJAS_KEY}`,
// },
// })
// .then((res) => {
// setFact(res.data[0].fact);
// });
axios.get(`https://picsum.photos/200`).then((res) => {
setImage(res.request.responseURL);
});
axios
.get("https://api.api-ninjas.com/v1/facts", {
headers: {
"X-Api-Key": `${import.meta.env.VITE_API_NINJAS_KEY}`,
},
})
.then((res) => {
setFact(res.data[0].fact);
});

axiosInstance
.get(`/chats/find/${id}/${user.id}`)
Expand Down Expand Up @@ -102,7 +102,8 @@ const Chat = () => {
navigate("/login");
} else {
fetchUserChat();
const newSocket = io("http://localhost:3000");
// const newSocket = io("http://localhost:3000");
const newSocket = io("https://ec2-65-2-83-179.ap-south-1.compute.amazonaws.com:3000");
setSocket(newSocket);
return () => newSocket.disconnect();
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/utils/interceptor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";

export const baseUrl = "http://localhost:5000/api";
// export const baseUrl = "http://localhost:5000/api";
export const baseUrl = "https://ec2-65-2-83-179.ap-south-1.compute.amazonaws.com:5000/api";

const axiosInstance = axios.create({
baseURL: baseUrl,
Expand Down
10 changes: 10 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
FROM node:18-alpine

# Pass environment variables as build arguments
ARG PORT
ARG MONGO_URI
ARG JWT_KEY

# Optionally, you can export these as environment variables
ENV PORT=${PORT}
ENV MONGO_URI=${MONGO_URI}
ENV JWT_KEY=${JWT_KEY}

COPY package*.json ./

RUN npm install
Expand Down
4 changes: 4 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ app.use(authenticateToken);
app.use('/api/chats', chatRouter);
app.use('/api/messages', messageRouter);

app.get('/health', (req, res) => {
res.status(200).send('Server is running');
});

app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
3 changes: 2 additions & 1 deletion socket/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Server } from "socket.io";

const io = new Server({
cors: "http://localhost:5173/",
// cors: "http://localhost:5173/",
cors: "https://we-chat-rho.vercel.app/",
});

let onlineUsers = [];
Expand Down

0 comments on commit 7b00542

Please sign in to comment.