Skip to content

Commit

Permalink
fixing port for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
vdnnguyen94 committed Mar 3, 2024
1 parent 3127c36 commit 7e4e0c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import react from '@vitejs/plugin-react';
import dotenv from 'dotenv';
dotenv.config();

const { PORT = 8000 } = process.env;
const { PORT = 3000 } = process.env;

export default defineConfig({
base: './',
plugins: [react()],
server: {
port: 10000,
proxy: {
'/api': {
target: `http://localhost:${PORT}`,
Expand Down
7 changes: 4 additions & 3 deletions server/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
// server/index.ts
const express_1 = __importDefault(require("express"));
const db_1 = __importDefault(require("./config/db"));
const config_1 = __importDefault(require("./config/config"));
const cors_1 = __importDefault(require("cors"));
const helmet_1 = __importDefault(require("helmet"));
const compression_1 = __importDefault(require("compression"));
Expand All @@ -17,7 +18,7 @@ const user_routes_1 = __importDefault(require("./routes/user.routes")); // Updat
const auth_routes_1 = __importDefault(require("./routes/auth.routes")); // Update extension to .ts
const app = (0, express_1.default)();
console.log("PORT process.env: ", process.env.PORT);
const port = process.env.PORT || 8000;
//const port = process.env.PORT || 8000;
// Connect to MongoDB
(0, db_1.default)();
// Middleware
Expand All @@ -35,6 +36,6 @@ app.use('/', question_routes_1.default);
app.get('/', (req, res) => {
res.send('Hello from the server!');
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
app.listen(config_1.default.port, () => {
console.log(`Server is running on port ${config_1.default.port}`);
});
6 changes: 3 additions & 3 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import authRoutes from './routes/auth.routes'; // Update extension to .ts

const app = express();
console.log("PORT process.env: ", process.env.PORT);
const port = process.env.PORT || 8000;
//const port = process.env.PORT || 8000;

// Connect to MongoDB
connectDB();
Expand All @@ -37,6 +37,6 @@ app.get('/', (req, res) => {
res.send('Hello from the server!');
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
app.listen(config.port, () => {
console.log(`Server is running on port ${config.port}`);
});

0 comments on commit 7e4e0c0

Please sign in to comment.