From e41011025c63fa0c251997542ead625344d59887 Mon Sep 17 00:00:00 2001 From: Pudi-Sravan Date: Fri, 5 Jul 2024 02:11:41 +0530 Subject: [PATCH] Added vercel.json --- .dockerignore | 5 ++++- docker-compose.yml | 2 ++ dockerfile-backend | 6 +++--- dockerfile-frontend | 9 ++++----- src/Back_end/Routes/apiroutes.js | 3 ++- src/Front_end/Authentication/loginpage/loginbox.jsx | 2 +- src/Front_end/Authentication/register/register.jsx | 2 +- src/Front_end/Mailing/mailsender.jsx | 4 ++-- src/Front_end/homepage/ToDo_list/assigntask.jsx | 4 ++-- src/Front_end/homepage/channels/addchannelmember.jsx | 4 ++-- src/Front_end/homepage/channels/channelchat.jsx | 4 ++-- src/Front_end/homepage/channels/membersofchannel.jsx | 12 ++++++------ .../homepage/googlecalendar.jsx/googlecalendar.jsx | 10 +++++----- src/Front_end/homepage/homepage.jsx | 2 +- vercel.json | 6 ++++++ vite.config.js | 5 +++++ 16 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 vercel.json diff --git a/.dockerignore b/.dockerignore index b8b21dd..720a889 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,5 @@ ./node_modules -src/Back_end/node_modules \ No newline at end of file +src/Back_end/node_modules +.env +src/Back_end/.env +.git \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a87827c..9e564d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: frontend: + image: slack-clone/frontend build: context: . dockerfile: dockerfile-frontend @@ -14,6 +15,7 @@ services: - backend backend: + image: slack-clone/backend build: context: . dockerfile: dockerfile-backend diff --git a/dockerfile-backend b/dockerfile-backend index 42d813b..816a647 100644 --- a/dockerfile-backend +++ b/dockerfile-backend @@ -9,16 +9,16 @@ COPY src/Back_end/package.json . COPY src/Back_end/package-lock.json . # Install all dependencies including devDependencies -RUN npm install --production=false +RUN npm install --production=true # Copy the rest of the backend application code COPY src/Back_end . # Copy backend-specific .env file (if needed) -COPY src/Back_end/.env . +#COPY src/Back_end/.env . # Expose the port on which the backend server will run -EXPOSE 3000 +EXPOSE 10000 # Command to start the backend server CMD ["npm", "run", "start"] diff --git a/dockerfile-frontend b/dockerfile-frontend index 0dc70b2..0bda3d0 100644 --- a/dockerfile-frontend +++ b/dockerfile-frontend @@ -8,19 +8,18 @@ WORKDIR /app COPY package.json . COPY package-lock.json . -# Install all dependencies including devDependencies -RUN npm install --production=false +# Install all dependencies including production only +RUN npm install --production # Copy the rest of the frontend application code COPY src/Front_end ./src/Front_end # Copy frontend-specific files -COPY ./.env . COPY vite.config.js . COPY index.html . # Expose the port on which the frontend server will run -EXPOSE 5172 +EXPOSE 5173 # Command to start the frontend server -CMD ["npm", "run", "dev"] +CMD ["npm", "run", "build"] diff --git a/src/Back_end/Routes/apiroutes.js b/src/Back_end/Routes/apiroutes.js index 1a8cc26..2c3237f 100644 --- a/src/Back_end/Routes/apiroutes.js +++ b/src/Back_end/Routes/apiroutes.js @@ -7,6 +7,7 @@ const { google } = require("googleapis"); const calendar = google.calendar("v3"); require("dotenv").config(); router.use(express.json()); +console.log(process.env.Front_endURL) const client = new google.auth.OAuth2( process.env.CLIENT_ID, process.env.CLIENT_SECRET, @@ -84,7 +85,7 @@ router.get("/googleauth/redirect", async (req, res) => { const { tokens } = await client.getToken(code); client.setCredentials(tokens); req.session.tokens = tokens; - res.redirect("http://localhost:5172"); + res.redirect(process.env.Front_endURL); } catch (error) { console.error("Error handling OAuth2 redirect:", error); res.status(500).send("Error handling OAuth2 redirect"); diff --git a/src/Front_end/Authentication/loginpage/loginbox.jsx b/src/Front_end/Authentication/loginpage/loginbox.jsx index 766e455..601d917 100644 --- a/src/Front_end/Authentication/loginpage/loginbox.jsx +++ b/src/Front_end/Authentication/loginpage/loginbox.jsx @@ -21,7 +21,7 @@ function Login({ settoken, setUpdload }) { let { data, error } = await supabase.auth.signInWithOAuth({ provider: provider, options: { - redirectTo: window.location.origin + "/update-details", // Redirect to update-details after login + redirectTo: "https://slack-clone-3gvixgrvr-pudi-sravans-projects.vercel.app/" + "/update-details", // Redirect to update-details after login }, }); if (data) { diff --git a/src/Front_end/Authentication/register/register.jsx b/src/Front_end/Authentication/register/register.jsx index 79c229c..be02c10 100644 --- a/src/Front_end/Authentication/register/register.jsx +++ b/src/Front_end/Authentication/register/register.jsx @@ -42,7 +42,7 @@ function Register({ settoken }) { let { data, error } = await supabase.auth.signInWithOAuth({ provider: provider, options: { - redirectTo: window.location.origin + "/update-details", // Redirect to update-details after login + redirectTo: "https://slack-clone-3gvixgrvr-pudi-sravans-projects.vercel.app/" + "/update-details", // Redirect to update-details after login }, }); if (data) { diff --git a/src/Front_end/Mailing/mailsender.jsx b/src/Front_end/Mailing/mailsender.jsx index 0640b2c..b8bb890 100644 --- a/src/Front_end/Mailing/mailsender.jsx +++ b/src/Front_end/Mailing/mailsender.jsx @@ -67,8 +67,8 @@ const TodoListChanges = () => { !mailbool ) { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", diff --git a/src/Front_end/homepage/ToDo_list/assigntask.jsx b/src/Front_end/homepage/ToDo_list/assigntask.jsx index bf86a9f..1a6d2ec 100644 --- a/src/Front_end/homepage/ToDo_list/assigntask.jsx +++ b/src/Front_end/homepage/ToDo_list/assigntask.jsx @@ -206,8 +206,8 @@ const Assigntask = () => { await insert_taskid(task_id); try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", diff --git a/src/Front_end/homepage/channels/addchannelmember.jsx b/src/Front_end/homepage/channels/addchannelmember.jsx index 2e434fc..5112664 100644 --- a/src/Front_end/homepage/channels/addchannelmember.jsx +++ b/src/Front_end/homepage/channels/addchannelmember.jsx @@ -105,8 +105,8 @@ const Addmember = () => { console.log("mem update successful"); try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", diff --git a/src/Front_end/homepage/channels/channelchat.jsx b/src/Front_end/homepage/channels/channelchat.jsx index c204f50..495a032 100644 --- a/src/Front_end/homepage/channels/channelchat.jsx +++ b/src/Front_end/homepage/channels/channelchat.jsx @@ -289,8 +289,8 @@ export const Channelchats = () => { ) { try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", diff --git a/src/Front_end/homepage/channels/membersofchannel.jsx b/src/Front_end/homepage/channels/membersofchannel.jsx index 6e36b40..c447a49 100644 --- a/src/Front_end/homepage/channels/membersofchannel.jsx +++ b/src/Front_end/homepage/channels/membersofchannel.jsx @@ -313,8 +313,8 @@ const Showmembers = () => { try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", @@ -382,8 +382,8 @@ const Showmembers = () => { try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", @@ -451,8 +451,8 @@ const Showmembers = () => { if (memresult) { try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/sendUserEmail`, { method: "POST", diff --git a/src/Front_end/homepage/googlecalendar.jsx/googlecalendar.jsx b/src/Front_end/homepage/googlecalendar.jsx/googlecalendar.jsx index 679b8c4..8f22e05 100644 --- a/src/Front_end/homepage/googlecalendar.jsx/googlecalendar.jsx +++ b/src/Front_end/homepage/googlecalendar.jsx/googlecalendar.jsx @@ -89,8 +89,8 @@ const Googlecalendar = () => { } const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/events?timeMin=${encodeURIComponent( timeMin )}&timeMax=${encodeURIComponent(timeMax)}` @@ -112,7 +112,7 @@ const Googlecalendar = () => { const handleAddEvent = async (eventData) => { try { const response = await fetch( - `http://localhost:${import.meta.env.VITE_Backend_Port}/api/createEvent`, + `${import.meta.env.VITE_Backend_URL}/api/createEvent`, { method: "POST", headers: { @@ -138,8 +138,8 @@ const Googlecalendar = () => { const handleDeleteEvent = async (eventId) => { try { const response = await fetch( - `http://localhost:${ - import.meta.env.VITE_Backend_Port + `${ + import.meta.env.VITE_Backend_URL }/api/eventsdelete/${eventId}`, { method: "DELETE", diff --git a/src/Front_end/homepage/homepage.jsx b/src/Front_end/homepage/homepage.jsx index 2ff21bd..17f20be 100644 --- a/src/Front_end/homepage/homepage.jsx +++ b/src/Front_end/homepage/homepage.jsx @@ -239,7 +239,7 @@ function Home(data) { const calendarAuth = async () => { try { const response = await fetch( - `http://localhost:${import.meta.env.VITE_Backend_Port}/api/googleauth`, + `${import.meta.env.VITE_Backend_URL}/api/googleauth`, { method: "GET", headers: { diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..ed82833 --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{"rewrites":[ + { + "source":"/(.*)", + "destination":"/" + } +]} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 98bcc10..86762ce 100644 --- a/vite.config.js +++ b/vite.config.js @@ -8,4 +8,9 @@ export default defineConfig({ "/src/main.jsx": "/src/Front_end/main.jsx", }, }, + server:{ + host:true, + strictPort:true, + port:5173 + } }); \ No newline at end of file